GNU bug report logs - #32378
[PATCH] bibtex-next/previous-entry

Previous Next

Package: emacs;

Reported by: Alex Branham <alex.branham <at> gmail.com>

Date: Mon, 6 Aug 2018 21:04:02 UTC

Severity: wishlist

Tags: fixed, patch

Fixed in version 27.1

Done: Noam Postavsky <npostavs <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32378 in the body.
You can then email your comments to 32378 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Mon, 06 Aug 2018 21:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alex Branham <alex.branham <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 06 Aug 2018 21:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] bibtex-next/previous-entry
Date: Mon, 06 Aug 2018 16:03:30 -0500
[Message part 1 (text/plain, inline)]
This patch adds two functions in bibtex-modeto navigate forward or
backward by entry.

I also bind them to M-{ and M-} because the paragraph forward/backward
commands in bibtex-mode just go up and down single lines, which you can
just use C-n/p to do more easily.

Let me know if something looks off.

Thanks,
Alex

---

From 406d6d438f890adb03a77c1bc15096db68f13fa7 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham <at> utexas.edu>
Date: Mon, 6 Aug 2018 15:47:12 -0500
Subject: [PATCH] * lisp/textmodes/bibtex.el: New functions
 bibtex-next/previous-entry

(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                 |  5 +++++
 lisp/textmodes/bibtex.el | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index 21887f5bfd..a3c06a3cb5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -232,6 +232,11 @@ 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
+They are bound to M-{ and M-} in bibtex-mode-map.
+
 +++
 ** Dired

diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 50a30cf6c3..966e774ae5 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 "\M-\}" 'bibtex-next-entry)
+    (define-key km "\M-\{" '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,20 @@ 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."
+  (interactive "p")
+  (bibtex-end-of-entry)
+  (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."
+  (interactive "p")
+  (bibtex-beginning-of-entry)
+  (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.
--
2.18.0


[0001-lisp-textmodes-bibtex.el-New-functions-bibtex-next-p.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Tue, 07 Aug 2018 02:16:01 GMT) Full text and rfc822 format available.

Message #8 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: 32378 <at> debbugs.gnu.org
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Mon, 06 Aug 2018 22:15:18 -0400
Alex Branham <alex.branham <at> gmail.com> writes:

> +(defun bibtex-next-entry (&optional arg)
> +  "Move point ARG entries forward."
> +  (interactive "p")
> +  (bibtex-end-of-entry)
> +  (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."
> +  (interactive "p")
> +  (bibtex-beginning-of-entry)
> +  (re-search-backward bibtex-entry-maybe-empty-head nil t (or arg 1))
> +  (goto-char (match-beginning 0)))

You forgot to check the return value of re-search-forward/backward, if
there is no match then (match-beginning 0) might return something
unexpected.  Alternatively, if you don't expect the match to fail, pass
nil for NOERROR.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Tue, 07 Aug 2018 09:21:01 GMT) Full text and rfc822 format available.

Message #11 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: 32378 <at> debbugs.gnu.org
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Tue, 07 Aug 2018 12:19:46 +0300
Alex Branham <alex.branham <at> gmail.com> writes:

> This patch adds two functions in bibtex-modeto navigate forward or
> backward by entry.
>
> I also bind them to M-{ and M-} because the paragraph forward/backward
> commands in bibtex-mode just go up and down single lines, which you can
> just use C-n/p to do more easily.

Are these commands (or could they be made) suitable for use with
beginning-of-defun-function and end-of-defun-function, as discussed in
the following messages?

https://lists.gnu.org/archive/html/emacs-devel/2018-05/msg00820.html
https://lists.gnu.org/archive/html/emacs-devel/2018-05/msg00821.html

Thanks,

-- 
Basil




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Tue, 07 Aug 2018 13:04:02 GMT) Full text and rfc822 format available.

Message #14 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 32378 <at> debbugs.gnu.org
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Tue, 07 Aug 2018 08:03:31 -0500
[Message part 1 (text/plain, inline)]
On Mon 06 Aug 2018 at 21:15, Noam Postavsky <npostavs <at> gmail.com> wrote:

> You forgot to check the return value of re-search-forward/backward, if
> there is no match then (match-beginning 0) might return something
> unexpected.

Yes, totally forgot that. Updated with new patch which just wraps that
in a call to when.

> Alternatively, if you don't expect the match to fail, pass nil for
> NOERROR.

The match can fail if point is at the beginning/end of the buffer, so I
think NOERROR needs to be non-nil.

---

From 3720b4a53bece9ddfde526093e3a537a1dace5e5 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham <at> utexas.edu>
Date: Mon, 6 Aug 2018 15:47:12 -0500
Subject: [PATCH] * lisp/textmodes/bibtex.el: New functions
 bibtex-next/previous-entry

(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                 |  5 +++++
 lisp/textmodes/bibtex.el | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index 21887f5bfd..a3c06a3cb5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -232,6 +232,11 @@ 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
+They are bound to M-{ and M-} in bibtex-mode-map.
+
 +++
 ** Dired
 
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 50a30cf6c3..56352bd20e 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 "\M-\}" 'bibtex-next-entry)
+    (define-key km "\M-\{" '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,20 @@ 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."
+  (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."
+  (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.
-- 
2.18.0


[0001-lisp-textmodes-bibtex.el-New-functions-bibtex-next-p.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Tue, 07 Aug 2018 13:08:02 GMT) Full text and rfc822 format available.

Message #17 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 32378 <at> debbugs.gnu.org
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Tue, 07 Aug 2018 08:07:12 -0500
On Tue 07 Aug 2018 at 04:19, Basil L. Contovounesios <contovob <at> tcd.ie> wrote:

> Are these commands (or could they be made) suitable for use with
> beginning-of-defun-function and end-of-defun-function, as discussed in
> the following messages?
>
> https://lists.gnu.org/archive/html/emacs-devel/2018-05/msg00820.html
> https://lists.gnu.org/archive/html/emacs-devel/2018-05/msg00821.html

Thanks for bringing those to my attention; I don't subscribe to emacs-devel.

We could certainly modify bibtex-beginning-of-entry to take an optional
argument that allows it to move past the current entry if point is
already at the beginning. I wouldn't want to modify the current behavior
because other packages rely on bibtex-beginning/end-of-entry not to move
past the current one (e.g. bibtex-completion.el and org-ref.el). 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Sun, 12 Aug 2018 17:42:01 GMT) Full text and rfc822 format available.

Message #20 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: 32378 <at> debbugs.gnu.org
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Sun, 12 Aug 2018 13:41:10 -0400
Alex Branham <alex.branham <at> gmail.com> writes:

> @@ -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 "\M-\}" 'bibtex-next-entry)
> +    (define-key km "\M-\{" 'bibtex-previous-entry)

Would it make sense to use [remap forward-paragraph] and [remap
backward-paragraph] instead of "\M-\}" and "\M-\{"?  (I guess the
question is how "paragraph-like" are these movement commands)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Mon, 20 Aug 2018 19:25:01 GMT) Full text and rfc822 format available.

Message #23 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: 32378 <at> debbugs.gnu.org
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Mon, 20 Aug 2018 14:23:58 -0500
[Message part 1 (text/plain, inline)]
On Sun 12 Aug 2018 at 12:41, Noam Postavsky <npostavs <at> gmail.com> wrote:

> Would it make sense to use [remap forward-paragraph] and [remap
> backward-paragraph] instead of "\M-\}" and "\M-\{"?  (I guess the
> question is how "paragraph-like" are these movement commands)

Yes, that probably makes sense. Revised patch attached.

Thanks!
Alex

---

From d329f0c7465e7c8d66b918eb984be6863a895544 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham <at> utexas.edu>
Date: Mon, 6 Aug 2018 15:47:12 -0500
Subject: [PATCH] * lisp/textmodes/bibtex.el: New functions
 bibtex-next/previous-entry

(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                 |  5 +++++
 lisp/textmodes/bibtex.el | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index a9f8ed2ef8..2145983afa 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -255,6 +255,11 @@ 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
+They are bound to M-{ and M-} in bibtex-mode-map.
+
 +++
 ** Dired
 
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index 50a30cf6c3..fccaed7cac 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,20 @@ 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."
+  (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."
+  (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.
-- 
2.18.0

[0001-lisp-textmodes-bibtex.el-New-functions-bibtex-next-p.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Tue, 21 Aug 2018 00:48:01 GMT) Full text and rfc822 format available.

Message #26 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: 32378 <at> debbugs.gnu.org
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Mon, 20 Aug 2018 20:47:25 -0400
Alex Branham <alex.branham <at> gmail.com> writes:

> On Sun 12 Aug 2018 at 12:41, Noam Postavsky <npostavs <at> gmail.com> wrote:
>
>> Would it make sense to use [remap forward-paragraph] and [remap
>> backward-paragraph] instead of "\M-\}" and "\M-\{"?  (I guess the
>> question is how "paragraph-like" are these movement commands)
>
> Yes, that probably makes sense. Revised patch attached.

>  etc/NEWS                 |  5 +++++
>  lisp/textmodes/bibtex.el | 18 ++++++++++++++++++

> ++++
> +** bibtex
> +*** New commands bibtex-next-entry and bibtex-previous-entry
> +They are bound to M-{ and M-} in bibtex-mode-map.

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)?

> +    (define-key km [remap forward-paragraph] 'bibtex-next-entry)
> +    (define-key km [remap backward-paragraph] 'bibtex-previous-entry)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Tue, 21 Aug 2018 02:29:02 GMT) Full text and rfc822 format available.

Message #29 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: 32378 <at> debbugs.gnu.org, npostavs <at> gmail.com
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Tue, 21 Aug 2018 05:28:27 +0300
> From: Alex Branham <alex.branham <at> gmail.com>
> Date: Mon, 20 Aug 2018 14:23:58 -0500
> Cc: 32378 <at> debbugs.gnu.org
> 
> > Would it make sense to use [remap forward-paragraph] and [remap
> > backward-paragraph] instead of "\M-\}" and "\M-\{"?  (I guess the
> > question is how "paragraph-like" are these movement commands)
> 
> Yes, that probably makes sense. Revised patch attached.

Thanks.

> ++++
> +** bibtex
> +*** New commands bibtex-next-entry and bibtex-previous-entry

Missing period at end of sentence.  Also, please quote command 'like
this'.

> +They are bound to M-{ and M-} in bibtex-mode-map.
> +
>  +++
>  ** Dired
>  
> diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
> index 50a30cf6c3..fccaed7cac 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,20 @@ 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."

We usually say in the doc string that interactively ARG is the prefix
argument.  Also that the default is 1 if ARG is omitted or nil.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Tue, 21 Aug 2018 15:20:02 GMT) Full text and rfc822 format available.

Message #32 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 32378 <at> debbugs.gnu.org
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Tue, 21 Aug 2018 10:19:50 -0500
[Message part 1 (text/plain, inline)]
>
> 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 <branham <at> utexas.edu>
Date: Mon, 6 Aug 2018 15:47:12 -0500
Subject: [PATCH] * lisp/textmodes/bibtex.el: New functions
 bibtex-next/previous-entry

(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
+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.
-- 
2.18.0

[0001-lisp-textmodes-bibtex.el-New-functions-bibtex-next-p.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Tue, 21 Aug 2018 15:22:06 GMT) Full text and rfc822 format available.

Message #35 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 32378 <at> debbugs.gnu.org
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Tue, 21 Aug 2018 10:21:39 -0500
Sorry, sent the wrong patch. This is the right one:

Alex

--------

From 430b4d956456d8567dd51172187f3457e8a9c045 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham <at> utexas.edu>
Date: Mon, 6 Aug 2018 15:47:12 -0500
Subject: [PATCH] * lisp/textmodes/bibtex.el: New functions
 bibtex-next/previous-entry

(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..58efcd1689 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
+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.
-- 
2.18.0





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Tue, 21 Aug 2018 15:24:02 GMT) Full text and rfc822 format available.

Message #38 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: Alex Branham <alex.branham <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 32378 <at> debbugs.gnu.org
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Tue, 21 Aug 2018 10:23:05 -0500
On Mon 20 Aug 2018 at 21:28, Eli Zaretskii <eliz <at> gnu.org> wrote:

>> +** bibtex
>> +*** New commands bibtex-next-entry and bibtex-previous-entry
>
> Missing period at end of sentence.  Also, please quote command 'like
> this'.

Added. Just FYI the period at the end of a heading seems to be inconsistent throughout the NEWS file.

>> +(defun bibtex-next-entry (&optional arg)
>> +  "Move point ARG entries forward."
>
> We usually say in the doc string that interactively ARG is the prefix
> argument.  Also that the default is 1 if ARG is omitted or nil.

Done. I attached the patch in the other thread.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Tue, 21 Aug 2018 16:10:01 GMT) Full text and rfc822 format available.

Message #41 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: 32378 <at> debbugs.gnu.org
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Tue, 21 Aug 2018 19:09:16 +0300
> From: Alex Branham <alex.branham <at> gmail.com>
> Cc: 32378 <at> debbugs.gnu.org
> Date: Tue, 21 Aug 2018 10:23:05 -0500
> 
> Just FYI the period at the end of a heading seems to be inconsistent throughout the NEWS file.

Thanks, I fixed the few ones that didn't use the right format.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32378; Package emacs. (Mon, 27 Aug 2018 23:57:01 GMT) Full text and rfc822 format available.

Message #44 received at 32378 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Alex Branham <alex.branham <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 32378 <at> debbugs.gnu.org
Subject: Re: bug#32378: [PATCH] bibtex-next/previous-entry
Date: Mon, 27 Aug 2018 19:56:16 -0400
tags 32378 fixed
close 32378 27.1
quit

Alex Branham <alex.branham <at> gmail.com> writes:

> Sorry, sent the wrong patch. This is the right one:

Pushed to master.

[1: 717b0341aa]: 2018-08-27 19:55:04 -0400
  New commands bibtex-next/previous-entry (Bug#32378)
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=717b0341aafb9ae9b93395dba1192b12c4459f0c




Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 27 Aug 2018 23:57:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 32378 <at> debbugs.gnu.org and Alex Branham <alex.branham <at> gmail.com> Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 27 Aug 2018 23:57:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 25 Sep 2018 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 280 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.