unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#42993: 26.3; [PATCH] Let Info bookmarks go to current, not recorded, version of manual
@ 2020-08-23  6:07 Drew Adams
  2020-08-23  6:26 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2020-08-23  6:07 UTC (permalink / raw)
  To: 42993

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

An Info bookmark, like most bookmarks, records the target file as an
absolute file name.  When you jump to an Info bookmark it jumps to the
recorded node in that Info file.

But what if you have Info bookmarks that were recorded for older Emacs
versions?  They typically have different absolute file names.  When you
jump to such a bookmark it will go to the manual for that older Emacs
version, if you still have it installed (and the Info files are at the
same locations as recorded by the bookmark).

This is a feature: you can have Info bookmarks to manuals for different
Emacs versions.  As long as those manuals are still available, bookmarks
to them continue to work.

But this behavior might not be what you want, in general.  In
particular, if an older, recorded Info file is no longer present, then
jumping to the bookmark just takes you to the top of Info (`dir') in the
manual that corresponds to the current Emacs session, and you're shown
an error message saying that the file in question doesn't exist.

The attached patch (from today's master) does two related things:

1. It adds a user option, `Info-bookmark-use-current-manual', which if
   non-nil makes Info bookmarks use the current manual, that is, the
   manual of the current Emacs session.

   The default value is nil, only for backward compatibility.  It gives
   you the behavior before the patch.

   I personally think the default value should be t, as I think the old
   behavior is essentially broken.  You decide.

2. If the option value is nil, and if the targeted Info file can't be
   found, then instead of raising an error you're taken to the target
   node in the current manual.

Another possibility would be to consider that users may often want to
toggle between the two behaviors, e.g., usually use the latest manuals
but sometimes use a recorded manual.  In that case, a non-option
variable might be better, along with a toggle command.

Still another possibility would be to give users a way to specify (when
creating an Info bookmark or later, by editing it), whether they want it
to go to the latest (current) manual or be tied to the recorded manual.
IOW, put the behavior specified by the variable in the bookmark instead.
IF a bookmark has some particular field value THEN respect its absolute
file name.  OTHERWISE, use the current Info manual.

That last possibility could be combined with the use of the variable, by
changing the OTHERWISE clause to follow the behavior specified by the
variable.

In GNU Emacs 26.3 (build 1, x86_64-w64-mingw32)
 of 2019-08-29
Repository revision: 96dd0196c28bc36779584e47fffcca433c9309cd
Windowing system distributor `Microsoft Corp.', version 10.0.18362
Configured using:
 `configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static -g3''

[-- Attachment #2: info-2020-08-22a.patch --]
[-- Type: application/octet-stream, Size: 1856 bytes --]

diff -u info.el info-2020-08-22a-PATCHED.el
--- info.el	2020-08-22 22:07:06.722986400 -0700
+++ info-2020-08-22a-PATCHED.el	2020-08-22 22:40:01.371990300 -0700
@@ -382,6 +382,12 @@
   :type 'hook
   :group 'info)
 
+(defcustom Info-bookmark-use-current-manual nil
+  "Non-nil means Info bookmarks use the manuals for this Emacs version.
+Otherwise they use the manuals whose absolute file names are recorded
+in the bookmarks."
+  :type 'boolean :group 'info)
+
 (defvar-local Info-current-file nil
   "Info file that Info is now looking at, or nil.
 This is the name that was specified in Info, not the actual file name.
@@ -5347,10 +5353,18 @@
 ;;;###autoload
 (defun Info-bookmark-jump (bmk)
   "This implements the `handler' function interface for the record
-type returned by `Info-bookmark-make-record', which see."
-  (let* ((file                   (bookmark-prop-get bmk 'filename))
+type returned by `Info-bookmark-make-record', which see.
+
+If `Info-bookmark-use-current-manual' is nil, and the recorded Info
+file exists, then use it.  If not, then go to the recorded Info node
+in the manual for the current Emacs version."
+  (let* ((absfile                (bookmark-prop-get bmk 'filename))
+         (file                   (if (or Info-bookmark-use-current-manual
+                                         (not (file-exists-p absfile)))
+                                     (file-name-nondirectory absfile)
+                                   absfile))
          (info-node              (bookmark-prop-get bmk 'info-node))
-         (buf (save-window-excursion    ;FIXME: doesn't work with frames!
+         (buf (save-window-excursion ; FIXME: doesn't work with frames!
                 (Info-find-node file info-node) (current-buffer))))
     ;; Use bookmark-default-handler to move to the appropriate location
     ;; within the node.

^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <<1e8dbcb9-e47f-48fd-a34a-f1cf304ba4cc@default>]

end of thread, other threads:[~2021-05-13  9:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-23  6:07 bug#42993: 26.3; [PATCH] Let Info bookmarks go to current, not recorded, version of manual Drew Adams
2020-08-23  6:26 ` Eli Zaretskii
     [not found] <<1e8dbcb9-e47f-48fd-a34a-f1cf304ba4cc@default>
     [not found] ` <<83mu2l98tg.fsf@gnu.org>
2020-08-23 16:32   ` Drew Adams
2020-08-30 21:03     ` Drew Adams
2021-05-13  9:55       ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).