* bug#32378: [PATCH] bibtex-next/previous-entry
@ 2018-08-06 21:03 Alex Branham
2018-08-07 2:15 ` Noam Postavsky
2018-08-07 9:19 ` Basil L. Contovounesios
0 siblings, 2 replies; 14+ messages in thread
From: Alex Branham @ 2018-08-06 21:03 UTC (permalink / raw)
To: 32378
[-- Attachment #1: Type: text/plain, Size: 3008 bytes --]
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@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.
\f
* 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-textmodes-bibtex.el-New-functions-bibtex-next-p.patch --]
[-- Type: text/x-patch, Size: 2690 bytes --]
From 406d6d438f890adb03a77c1bc15096db68f13fa7 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham@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.
\f
* 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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* bug#32378: [PATCH] bibtex-next/previous-entry
2018-08-06 21:03 bug#32378: [PATCH] bibtex-next/previous-entry Alex Branham
@ 2018-08-07 2:15 ` Noam Postavsky
2018-08-07 13:03 ` Alex Branham
2018-08-07 9:19 ` Basil L. Contovounesios
1 sibling, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2018-08-07 2:15 UTC (permalink / raw)
To: Alex Branham; +Cc: 32378
Alex Branham <alex.branham@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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#32378: [PATCH] bibtex-next/previous-entry
2018-08-07 2:15 ` Noam Postavsky
@ 2018-08-07 13:03 ` Alex Branham
2018-08-12 17:41 ` Noam Postavsky
0 siblings, 1 reply; 14+ messages in thread
From: Alex Branham @ 2018-08-07 13:03 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32378
[-- Attachment #1: Type: text/plain, Size: 3224 bytes --]
On Mon 06 Aug 2018 at 21:15, Noam Postavsky <npostavs@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@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.
\f
* 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-textmodes-bibtex.el-New-functions-bibtex-next-p.patch --]
[-- Type: text/x-patch, Size: 2708 bytes --]
From 3720b4a53bece9ddfde526093e3a537a1dace5e5 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham@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.
\f
* 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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* bug#32378: [PATCH] bibtex-next/previous-entry
2018-08-07 13:03 ` Alex Branham
@ 2018-08-12 17:41 ` Noam Postavsky
2018-08-20 19:23 ` Alex Branham
0 siblings, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2018-08-12 17:41 UTC (permalink / raw)
To: Alex Branham; +Cc: 32378
Alex Branham <alex.branham@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)
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#32378: [PATCH] bibtex-next/previous-entry
2018-08-12 17:41 ` Noam Postavsky
@ 2018-08-20 19:23 ` Alex Branham
2018-08-21 0:47 ` Noam Postavsky
2018-08-21 2:28 ` Eli Zaretskii
0 siblings, 2 replies; 14+ messages in thread
From: Alex Branham @ 2018-08-20 19:23 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32378
[-- Attachment #1: Type: text/plain, Size: 3094 bytes --]
On Sun 12 Aug 2018 at 12:41, Noam Postavsky <npostavs@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@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.
\f
* 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-textmodes-bibtex.el-New-functions-bibtex-next-p.patch --]
[-- Type: text/x-patch, Size: 2745 bytes --]
From d329f0c7465e7c8d66b918eb984be6863a895544 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham@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.
\f
* 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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* bug#32378: [PATCH] bibtex-next/previous-entry
2018-08-20 19:23 ` Alex Branham
@ 2018-08-21 0:47 ` Noam Postavsky
2018-08-21 15:19 ` Alex Branham
2018-08-21 2:28 ` Eli Zaretskii
1 sibling, 1 reply; 14+ messages in thread
From: Noam Postavsky @ 2018-08-21 0:47 UTC (permalink / raw)
To: Alex Branham; +Cc: 32378
Alex Branham <alex.branham@gmail.com> writes:
> On Sun 12 Aug 2018 at 12:41, Noam Postavsky <npostavs@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)
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#32378: [PATCH] bibtex-next/previous-entry
2018-08-21 0:47 ` Noam Postavsky
@ 2018-08-21 15:19 ` Alex Branham
2018-08-21 15:21 ` Alex Branham
0 siblings, 1 reply; 14+ messages in thread
From: Alex Branham @ 2018-08-21 15:19 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32378
[-- Attachment #1: Type: text/plain, Size: 3294 bytes --]
>
> 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@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.
\f
* 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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-textmodes-bibtex.el-New-functions-bibtex-next-p.patch --]
[-- Type: text/x-patch, Size: 2948 bytes --]
From 579953250b3e7f9c2f804dd609a373e31f393518 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham@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.
\f
* 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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* bug#32378: [PATCH] bibtex-next/previous-entry
2018-08-21 15:19 ` Alex Branham
@ 2018-08-21 15:21 ` Alex Branham
2018-08-27 23:56 ` Noam Postavsky
0 siblings, 1 reply; 14+ messages in thread
From: Alex Branham @ 2018-08-21 15:21 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 32378
Sorry, sent the wrong patch. This is the right one:
Alex
--------
From 430b4d956456d8567dd51172187f3457e8a9c045 Mon Sep 17 00:00:00 2001
From: Alex Branham <branham@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.
\f
* 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
^ permalink raw reply related [flat|nested] 14+ messages in thread
* bug#32378: [PATCH] bibtex-next/previous-entry
2018-08-20 19:23 ` Alex Branham
2018-08-21 0:47 ` Noam Postavsky
@ 2018-08-21 2:28 ` Eli Zaretskii
2018-08-21 15:23 ` Alex Branham
1 sibling, 1 reply; 14+ messages in thread
From: Eli Zaretskii @ 2018-08-21 2:28 UTC (permalink / raw)
To: Alex Branham; +Cc: 32378, npostavs
> From: Alex Branham <alex.branham@gmail.com>
> Date: Mon, 20 Aug 2018 14:23:58 -0500
> Cc: 32378@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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#32378: [PATCH] bibtex-next/previous-entry
2018-08-21 2:28 ` Eli Zaretskii
@ 2018-08-21 15:23 ` Alex Branham
2018-08-21 16:09 ` Eli Zaretskii
0 siblings, 1 reply; 14+ messages in thread
From: Alex Branham @ 2018-08-21 15:23 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 32378
On Mon 20 Aug 2018 at 21:28, Eli Zaretskii <eliz@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.
^ permalink raw reply [flat|nested] 14+ messages in thread
* bug#32378: [PATCH] bibtex-next/previous-entry
2018-08-06 21:03 bug#32378: [PATCH] bibtex-next/previous-entry Alex Branham
2018-08-07 2:15 ` Noam Postavsky
@ 2018-08-07 9:19 ` Basil L. Contovounesios
2018-08-07 13:07 ` Alex Branham
1 sibling, 1 reply; 14+ messages in thread
From: Basil L. Contovounesios @ 2018-08-07 9:19 UTC (permalink / raw)
To: Alex Branham; +Cc: 32378
Alex Branham <alex.branham@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
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2018-08-27 23:56 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-06 21:03 bug#32378: [PATCH] bibtex-next/previous-entry Alex Branham
2018-08-07 2:15 ` Noam Postavsky
2018-08-07 13:03 ` Alex Branham
2018-08-12 17:41 ` Noam Postavsky
2018-08-20 19:23 ` Alex Branham
2018-08-21 0:47 ` Noam Postavsky
2018-08-21 15:19 ` Alex Branham
2018-08-21 15:21 ` Alex Branham
2018-08-27 23:56 ` Noam Postavsky
2018-08-21 2:28 ` Eli Zaretskii
2018-08-21 15:23 ` Alex Branham
2018-08-21 16:09 ` Eli Zaretskii
2018-08-07 9:19 ` Basil L. Contovounesios
2018-08-07 13:07 ` Alex Branham
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.