[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32378: [PATCH] bibtex-next/previous-entry

From: Alex Branham
Subject: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Tue, 21 Aug 2018 10:19:50 -0500
User-agent: mu4e 1.0; emacs 26.1

> I guess the NEWS entry should be revised as well.  I notice you put
> "+++" but haven't made any manual updates, did you mean "---" instead
> (i.e., no manual updates are required)?

Thanks, done. I wasn't sure if I should use "---" (no manual updates
required, which is true) or "+++" (all doc strings updated, which is
also true).


>From 579953250b3e7f9c2f804dd609a373e31f393518 Mon Sep 17 00:00:00 2001
From: Alex Branham <address@hidden>
Date: Mon, 6 Aug 2018 15:47:12 -0500
Subject: [PATCH] * lisp/textmodes/bibtex.el: New functions

(bibtex-next-entry, bibtex-previous-entry): new functions.
(bibtex-mode-map): Bind to M-{/}, overriding forward/backward
paragraph, which only move single lines in bibtex-mode
 etc/NEWS                 |  6 ++++++
 lisp/textmodes/bibtex.el | 22 ++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index a9f8ed2ef8..bb8fa5411e 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 50a30cf6c3..54aa3de433 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -1356,6 +1356,8 @@ bibtex-mode-map
     ;; 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 @@ bibtex-mode-map
     ("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 @@ bibtex-next-field
       (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
+  (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
+  (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.

Attachment: 0001-lisp-textmodes-bibtex.el-New-functions-bibtex-next-p.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]