all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Christopher Schmidt <christopher@ch.ristopher.com>
To: 11656@debbugs.gnu.org
Subject: bug#11656: 24.1.50; Info-\(next\|prev\)-reference: Add numeric prefix argument
Date: Sat,  9 Jun 2012 08:25:29 +0100 (BST)	[thread overview]
Message-ID: <874nqleylg@ch.ristopher.com> (raw)
In-Reply-To: <83vcj1t1xb.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 09 Jun 2012 09:49:36 +0300")

[-- Attachment #1: Type: text/plain, Size: 1378 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Christopher Schmidt <christopher@ch.ristopher.com>
>> Date: Sat,  9 Jun 2012 04:41:16 +0100 (BST)
>>
>> this patch adds the optional numeric prefix argument COUNT to
>> Info-next-reference and Info-prev-reference.  This argument makes the
>> functions do The Right Thing, that is, repeat the functionality COUNT
>> times.
>
> Thanks.  Can you present a use case where this functionality is
> needed?  Specifically, I wonder how a user would know how many Next or
> Prev nodes she needs to go to get to whatever she is looking for.
       ^^^^^

Uhm, Info-next-reference and Info-prev-reference navigate within the
cross references in the current buffer.  I think you mistake
Info-next-reference (bound to <tab>) with Info-forward-node (bound to
]).

Pressing <tab> in combination with a prefix argument is just a lot
easier, faster and less intrusive than the use of any regular movement
commands or a repeated pressing of <tab>.  A prefix argument that
specifies the repeat count is also pretty consistent with most other
movement commands, especially forward-button.  To me, this is The Right
Thing.  At least this is what my subconscious, which takes over when I
navigate within the first three nodes after pressing C-h i, told me.

Here is an improved version of my patch that also handles negative
prefix arguments correctly.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Info-nextprev-reference-v2.diff --]
[-- Type: text/x-diff, Size: 4212 bytes --]

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2012-06-09 02:26:47 +0000
+++ lisp/ChangeLog	2012-06-09 03:37:42 +0000
@@ -1,3 +1,8 @@
+2012-06-09  Christopher Schmidt  <christopher@ch.ristopher.com>
+
+	* info.el (Info-next-reference, Info-prev-reference): Add numeric
+	prefix argument.
+
 2012-06-09  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* emacs-lisp/macroexp.el (macroexp--expand-all): Only autoload

=== modified file 'lisp/info.el'
--- lisp/info.el	2012-06-08 04:23:26 +0000
+++ lisp/info.el	2012-06-09 07:09:28 +0000
@@ -2914,48 +2914,62 @@
 	(select-window (posn-window (event-start e))))
     (Info-scroll-down)))
 
-(defun Info-next-reference (&optional recur)
-  "Move cursor to the next cross-reference or menu item in the node."
-  (interactive)
-  (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tps?://")
-	(old-pt (point))
-	(case-fold-search t))
-    (or (eobp) (forward-char 1))
-    (or (re-search-forward pat nil t)
-	(progn
-	  (goto-char (point-min))
-	  (or (re-search-forward pat nil t)
-	      (progn
-		(goto-char old-pt)
-		(user-error "No cross references in this node")))))
-    (goto-char (or (match-beginning 1) (match-beginning 0)))
-    (if (looking-at "\\* Menu:")
-	(if recur
-	    (user-error "No cross references in this node")
-	  (Info-next-reference t))
-      (if (looking-at "^\\* ")
-	  (forward-char 2)))))
+(defun Info-next-reference (&optional recur count)
+  "Move cursor to the next cross-reference or menu item in the node.
+If COUNT is non-nil (interactively with a prefix arg), jump over
+COUNT cross-references."
+  (interactive "i\np")
+  (unless count
+    (setq count 1))
+  (if (< count 0)
+      (Info-prev-reference recur (- count))
+    (while (unless (zerop count) (setq count (1- count)))
+      (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tps?://")
+	    (old-pt (point))
+	    (case-fold-search t))
+	(or (eobp) (forward-char 1))
+	(or (re-search-forward pat nil t)
+	    (progn
+	      (goto-char (point-min))
+	      (or (re-search-forward pat nil t)
+		  (progn
+		    (goto-char old-pt)
+		    (user-error "No cross references in this node")))))
+	(goto-char (or (match-beginning 1) (match-beginning 0)))
+	(if (looking-at "\\* Menu:")
+	    (if recur
+		(user-error "No cross references in this node")
+	      (Info-next-reference t))
+	  (if (looking-at "^\\* ")
+	      (forward-char 2)))))))
 
-(defun Info-prev-reference (&optional recur)
-  "Move cursor to the previous cross-reference or menu item in the node."
-  (interactive)
-  (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tps?://")
-	(old-pt (point))
-	(case-fold-search t))
-    (or (re-search-backward pat nil t)
-	(progn
-	  (goto-char (point-max))
-	  (or (re-search-backward pat nil t)
-	      (progn
-		(goto-char old-pt)
-		(user-error "No cross references in this node")))))
-    (goto-char (or (match-beginning 1) (match-beginning 0)))
-    (if (looking-at "\\* Menu:")
-	(if recur
-	    (user-error "No cross references in this node")
-	  (Info-prev-reference t))
-      (if (looking-at "^\\* ")
-	  (forward-char 2)))))
+(defun Info-prev-reference (&optional recur count)
+  "Move cursor to the previous cross-reference or menu item in the node.
+If COUNT is non-nil (interactively with a prefix arg), jump over
+COUNT cross-references."
+  (interactive "i\np")
+  (unless count
+    (setq count 1))
+  (if (< count 0)
+      (Info-next-reference recur (- count))
+    (while (unless (zerop count) (setq count (1- count)))
+      (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tps?://")
+	    (old-pt (point))
+	    (case-fold-search t))
+	(or (re-search-backward pat nil t)
+	    (progn
+	      (goto-char (point-max))
+	      (or (re-search-backward pat nil t)
+		  (progn
+		    (goto-char old-pt)
+		    (user-error "No cross references in this node")))))
+	(goto-char (or (match-beginning 1) (match-beginning 0)))
+	(if (looking-at "\\* Menu:")
+	    (if recur
+		(user-error "No cross references in this node")
+	      (Info-prev-reference t))
+	  (if (looking-at "^\\* ")
+	      (forward-char 2)))))))
 \f
 (defvar Info-index-nodes nil
   "Alist of cached index node names of visited Info files.


[-- Attachment #3: Type: text/plain, Size: 21 bytes --]


        Christopher

  reply	other threads:[~2012-06-09  7:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-09  3:41 bug#11656: 24.1.50; Info-\(next\|prev\)-reference: Add numeric prefix argument Christopher Schmidt
2012-06-09  6:49 ` Eli Zaretskii
2012-06-09  7:25   ` Christopher Schmidt [this message]
2012-06-09  7:46     ` Eli Zaretskii
2012-06-09  7:59       ` Christopher Schmidt
2012-06-11 23:52         ` Juri Linkov
2012-06-24 15:15           ` Christopher Schmidt
2012-06-24 15:23             ` Christopher Schmidt
2013-01-13  8:55     ` Christopher Schmidt
2013-01-15 14:02       ` Stefan Monnier
2013-02-01 17:01         ` Christopher Schmidt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874nqleylg@ch.ristopher.com \
    --to=christopher@ch.ristopher.com \
    --cc=11656@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.