summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Branham <alex.branham@gmail.com>2018-08-21 10:21:39 -0500
committerNoam Postavsky <npostavs@gmail.com>2018-08-27 19:55:04 -0400
commit717b0341aafb9ae9b93395dba1192b12c4459f0c (patch)
tree2c57400e14f97c5bbaf10f409dfbc215a0307945
parent0250d22eeb8427cb87c58f528f337dc83d0419a5 (diff)
downloademacs-717b0341aafb9ae9b93395dba1192b12c4459f0c.tar.gz
emacs-717b0341aafb9ae9b93395dba1192b12c4459f0c.tar.bz2
emacs-717b0341aafb9ae9b93395dba1192b12c4459f0c.zip
New commands bibtex-next/previous-entry (Bug#32378)
* lisp/textmodes/bibtex.el (bibtex-next-entry) (bibtex-previous-entry): New commands. (bibtex-mode-map): Bind to to forward-paragraph and backward-paragraph. Add to menu under "Moving inside an Entry".
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/textmodes/bibtex.el22
2 files changed, 28 insertions, 0 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 4fc02e8f2a4..049863822a4 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -255,6 +255,12 @@ navigation and editing of large files.
* Changes in Specialized Modes and Packages in Emacs 27.1
+---
+** bibtex
+*** New commands 'bibtex-next-entry' and 'bibtex-previous-entry'.
+In bibtex-mode-map, forward-paragraph and backward-paragraph are
+remapped to these, respectively.
+
+++
** Dired
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 6f6b06266ef..57e5ef8017a 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -1356,6 +1356,8 @@ Set this variable before loading BibTeX mode."
;; The Key `C-c&' is reserved for reftex.el
(define-key km "\t" 'bibtex-find-text)
(define-key km "\n" 'bibtex-next-field)
+ (define-key km [remap forward-paragraph] 'bibtex-next-entry)
+ (define-key km [remap backward-paragraph] 'bibtex-previous-entry)
(define-key km "\M-\t" 'completion-at-point)
(define-key km "\C-c\"" 'bibtex-remove-delimiters)
(define-key km "\C-c{" 'bibtex-remove-delimiters)
@@ -1415,6 +1417,8 @@ Set this variable before loading BibTeX mode."
("Moving inside an Entry"
["End of Field" bibtex-find-text t]
["Next Field" bibtex-next-field t]
+ ["Next entry" bibtex-next-entry t]
+ ["Previous entry" bibtex-previous-entry t]
["Beginning of Entry" bibtex-beginning-of-entry t]
["End of Entry" bibtex-end-of-entry t]
"--"
@@ -4452,6 +4456,24 @@ is as in `bibtex-enclosing-field'. It is t for interactive calls."
(goto-char (match-beginning 0)))
(bibtex-find-text begin nil bibtex-help-message)))
+(defun bibtex-next-entry (&optional arg)
+ "Move point ARG entries forward.
+ARG defaults to one. Called interactively, ARG is the prefix
+argument."
+ (interactive "p")
+ (bibtex-end-of-entry)
+ (when (re-search-forward bibtex-entry-maybe-empty-head nil t (or arg 1))
+ (goto-char (match-beginning 0))))
+
+(defun bibtex-previous-entry (&optional arg)
+ "Move point ARG entries backward.
+ARG defaults to one. Called interactively, ARG is the prefix
+argument."
+ (interactive "p")
+ (bibtex-beginning-of-entry)
+ (when (re-search-backward bibtex-entry-maybe-empty-head nil t (or arg 1))
+ (goto-char (match-beginning 0))))
+
(defun bibtex-find-text (&optional begin noerror help comma)
"Move point to end of text of current BibTeX field or entry head.
With optional prefix BEGIN non-nil, move point to its beginning.