unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#12230: 24.2; revert-buffer in an Info buffer should refresh Info-index-nodes
@ 2012-08-18 18:15 Eli Zaretskii
  2012-08-18 22:31 ` Juri Linkov
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2012-08-18 18:15 UTC (permalink / raw)
  To: 12230

This problem cannot easily happen in "emacs -Q", so no reproducible
recipe, sorry.

However, the problem is quite clear: if you "M-x revert-buffer" in an
Info buffer, and the new Info file changed the names of its Index
nodes, then the 'i' command will most probably fail the next time you
invoke it in that Info buffer.

A case in point is the GDB manual: it recently split its Index node
into 2 nodes, called "Concept Index" and "Command and Variable Index",
respectively.  After reverting its Info buffer, 'i' started signaling
an error, complaining about the missing node "Index".

The problem is that info.el caches the Index nodes in the alist stored
in Info-index-nodes.  It should therefore remove from that alist the
association of the Info file whose buffer is reverted.


In GNU Emacs 24.2.1 (i386-mingw-nt5.1.2600)
 of 2012-08-16 on HOME-C4E4A596F7
Windowing system distributor `Microsoft Corp.', version 5.1.2600
Configured using:
 `configure --with-gcc (3.4)'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1255
  default enable-multibyte-characters: t

Major mode: Mail

Minor modes in effect:
  diff-auto-refine-mode: t
  flyspell-mode: t
  desktop-save-mode: t
  show-paren-mode: t
  display-time-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  line-number-mode: t
  abbrev-mode: t

Recent input:
C-x b I N B <tab> <return> <C-next> <C-next> <C-next> 
<C-next> <C-next> <C-next> <C-next> <C-next> <C-next> 
<C-next> <C-next> <C-next> <C-next> <M-end> M-: I n 
f o - i n d e x - m <backspace> n o d e s <return> 
<down> C-x b * s c r <tab> <return> I n f o - i n d 
e x - n o d e s C-j <left> <left> <left> <return> <down> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <help-echo> 
C-s g d b <up> C-x b <return> C-x 5 b x d <tab> <return> 
C-h f w 3 2 - a d d <tab> <return> <C-prior> <C-prior> 
<help-echo> <help-echo> <help-echo> <switch-frame> 
C-x 5 b * i n <tab> 2 4 > <return> <help-echo> <switch-frame> 
<help-echo> <switch-frame> <help-echo> i <help-echo> 
a u t o - l o a d <return> <switch-frame> <help-echo> 
<help-echo> <help-echo> <switch-frame> <switch-frame> 
<down> <up> <switch-frame> M-1 g <up> <return> o <return> 
o <up> <return> d C-x C-s <up> <up> <switch-frame> 
<switch-frame> M-1 g <up> <up> <return> d d d <switch-frame> 
<switch-frame> m <switch-frame> <switch-frame> M-x 
r e p o r t - e m <tab> <return>

Recent messages:
byte-code: Beginning of buffer [2 times]
Getting mail from d:/usr/eli/data/mail.new...
Counting new messages...done (3)
Saving file d:/usr/eli/rmail/INBOX...
Wrote d:/usr/eli/rmail/INBOX [2 times]
Computing summary lines...done
3 new messages read
No following nondeleted message
Parsing d:/usr/eli/.mailrc... done
Scanning for dabbrevs...done

Load-path shadows:
None found.

Features:
(shadow dabbrev emacsbug mailalias sendmail rmailout help-mode view
misearch multi-isearch texinfo tcl nxml-uchnm rng-xsd xsd-regexp
rng-cmpct rng-nxml rng-valid rng-loc rng-uri rng-parse nxml-parse
rng-match rng-dt rng-util rng-pttrn nxml-ns nxml-mode nxml-outln
nxml-rap nxml-util nxml-glyph nxml-enc xmltok sgml-mode make-mode
conf-mode newcomment parse-time generic ld-script sh-script executable
vc-git arc-mode archive-mode diff-mode dired-x dired jka-compr
autorevert vc-cvs face-remap org-wl org-w3m org-vm org-rmail org-mhe
org-mew org-irc org-jsinfo org-infojs org-html org-exp ob-exp
org-exp-blocks find-func org-agenda org-info org-gnus org-docview
org-bibtex bibtex org-bbdb org byte-opt warnings bytecomp byte-compile
cconv macroexp advice help-fns advice-preload ob-emacs-lisp ob-tangle
ob-ref ob-lob ob-table org-footnote org-src ob-comint ob-keys ob
ob-eval org-pcomplete pcomplete comint ansi-color ring org-list
org-faces org-compat org-entities org-macs noutline outline easy-mmode
cal-menu calendar cal-loaddefs flyspell info vc-bzr cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
regexp-opt qp rmailsum rmailmm message format-spec rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader
mail-parse rfc2231 rmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils desktop server filecache mairix cus-edit easymenu cus-start
cus-load wid-edit saveplace midnight ispell generic-x paren battery
time time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel
dos-w32 disp-table ls-lisp w32-win w32-vars tool-bar dnd fontset image
fringe lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet
lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook
help simple abbrev minibuffer loaddefs button faces cus-face files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
multi-tty emacs)





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#12230: 24.2; revert-buffer in an Info buffer should refresh Info-index-nodes
  2012-08-18 18:15 bug#12230: 24.2; revert-buffer in an Info buffer should refresh Info-index-nodes Eli Zaretskii
@ 2012-08-18 22:31 ` Juri Linkov
  2012-08-19  2:48   ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2012-08-18 22:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 12230

> The problem is that info.el caches the Index nodes in the alist stored
> in Info-index-nodes.  It should therefore remove from that alist the
> association of the Info file whose buffer is reverted.

Since `Info-revert-find-node' is not the right place to clear
the cache because the same problem can occur after killing
the Info buffer and revisiting the same Info manual manually,
perhaps the right fix would be to check the modtime of the Info file
in `Info-find-file' and clear the cache for modified files.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#12230: 24.2; revert-buffer in an Info buffer should refresh Info-index-nodes
  2012-08-18 22:31 ` Juri Linkov
@ 2012-08-19  2:48   ` Eli Zaretskii
  2012-08-19 23:39     ` Juri Linkov
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2012-08-19  2:48 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 12230

> From: Juri Linkov <juri@jurta.org>
> Cc: 12230@debbugs.gnu.org
> Date: Sun, 19 Aug 2012 01:31:17 +0300
> 
> > The problem is that info.el caches the Index nodes in the alist stored
> > in Info-index-nodes.  It should therefore remove from that alist the
> > association of the Info file whose buffer is reverted.
> 
> Since `Info-revert-find-node' is not the right place to clear
> the cache because the same problem can occur after killing
> the Info buffer and revisiting the same Info manual manually,
> perhaps the right fix would be to check the modtime of the Info file
> in `Info-find-file' and clear the cache for modified files.

That should do the trick, I think.  Thanks.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#12230: 24.2; revert-buffer in an Info buffer should refresh Info-index-nodes
  2012-08-19  2:48   ` Eli Zaretskii
@ 2012-08-19 23:39     ` Juri Linkov
  2012-08-20  2:45       ` Eli Zaretskii
  0 siblings, 1 reply; 9+ messages in thread
From: Juri Linkov @ 2012-08-19 23:39 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 12230

>> Since `Info-revert-find-node' is not the right place to clear
>> the cache because the same problem can occur after killing
>> the Info buffer and revisiting the same Info manual manually,
>> perhaps the right fix would be to check the modtime of the Info file
>> in `Info-find-file' and clear the cache for modified files.
>
> That should do the trick, I think.  Thanks.

Actually there are more caches that should be cleared.
The following patch should clear them:

=== modified file 'lisp/info.el'
--- lisp/info.el	2012-08-07 16:12:20 +0000
+++ lisp/info.el	2012-08-19 23:38:18 +0000
@@ -813,6 +816,10 @@ (defun Info-node-at-bob-matching (regexp
 	 (forward-line 1)		; does the line after delimiter match REGEXP?
 	 (re-search-backward regexp beg t))))
 
+(defvar Info-file-attributes nil
+  "List of the file attributes of visited Info files.
+Each element is a list (FILE-NAME FILE-ATTRIBUTES...).")
+
 (defun Info-find-file (filename &optional noerror)
   "Return expanded FILENAME, or t if FILENAME is \"dir\".
 Optional second argument NOERROR, if t, means if file is not found
@@ -875,6 +882,22 @@ (defun Info-find-file (filename &optiona
 	(if noerror
 	    (setq filename nil)
 	  (error "Info file %s does not exist" filename)))
+      ;; Clear the caches of modified Info files.
+      (let* ((attribs-old (cdr (assoc filename Info-file-attributes)))
+	     (modtime-old (and attribs-old (nth 5 attribs-old)))
+	     (attribs-new (and (stringp filename) (file-attributes filename)))
+	     (modtime-new (and attribs-new (nth 5 attribs-new))))
+	(when (and modtime-old modtime-new
+		   (> (float-time modtime-new) (float-time modtime-old)))
+	  (setq Info-index-nodes (remove (assoc filename Info-index-nodes)
+					 Info-index-nodes))
+	  (setq Info-toc-nodes (remove (assoc filename Info-toc-nodes)
+				       Info-toc-nodes)))
+	;; Add new modtime to `Info-file-attributes'.
+	(setq Info-file-attributes
+	      (cons (cons filename attribs-new)
+		    (remove (assoc filename Info-file-attributes)
+			    Info-file-attributes))))
       filename))))
 
 (defun Info-find-node (filename nodename &optional no-going-back)





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#12230: 24.2; revert-buffer in an Info buffer should refresh Info-index-nodes
  2012-08-19 23:39     ` Juri Linkov
@ 2012-08-20  2:45       ` Eli Zaretskii
  2012-08-21  0:15         ` Juri Linkov
  0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2012-08-20  2:45 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 12230

> From: Juri Linkov <juri@jurta.org>
> Cc: 12230@debbugs.gnu.org
> Date: Mon, 20 Aug 2012 02:39:29 +0300
> 
> >> Since `Info-revert-find-node' is not the right place to clear
> >> the cache because the same problem can occur after killing
> >> the Info buffer and revisiting the same Info manual manually,
> >> perhaps the right fix would be to check the modtime of the Info file
> >> in `Info-find-file' and clear the cache for modified files.
> >
> > That should do the trick, I think.  Thanks.
> 
> Actually there are more caches that should be cleared.
> The following patch should clear them:

Looks good to me, thanks.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#12230: 24.2; revert-buffer in an Info buffer should refresh Info-index-nodes
  2012-08-20  2:45       ` Eli Zaretskii
@ 2012-08-21  0:15         ` Juri Linkov
  2012-08-21  6:15           ` Chong Yidong
  2012-08-21  6:49           ` martin rudalics
  0 siblings, 2 replies; 9+ messages in thread
From: Juri Linkov @ 2012-08-21  0:15 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 12230

> Looks good to me, thanks.

Installed with cache invalidation for `Info-index-nodes' and
`Info-toc-nodes' (I had to put code to `info-insert-file-contents'
instead of `Info-find-file' because the full filename is available
only in the former).

There is also `Info-history' that contains information about nodes,
but I see no reasonable way to update `Info-history'
to reflect changes in the modified Info files.

BTW, let me use this opportunity to propose an improvement that restores
the original window point when returning back to the previous node.
This helps to avoid distraction when point jumps from the original
window position (displayed before leaving the Info node) to
another position (by default, center of the window):

=== modified file 'lisp/info.el'
--- lisp/info.el	2012-08-08 08:48:57 +0000
+++ lisp/info.el	2012-08-21 00:14:18 +0000
@@ -40,11 +40,11 @@ (defgroup info nil
 
 (defvar Info-history nil
   "Stack of Info nodes user has visited.
-Each element of the stack is a list (FILENAME NODENAME BUFFERPOS).")
+Each element of the stack is a list (FILENAME NODENAME BUFFERPOS WINDOWPOS).")
 
 (defvar Info-history-forward nil
   "Stack of Info nodes user has visited with `Info-history-back' command.
-Each element of the stack is a list (FILENAME NODENAME BUFFERPOS).")
+Each element of the stack is a list (FILENAME NODENAME BUFFERPOS WINDOWPOS).")
 
 (defvar Info-history-list nil
   "List of all Info nodes user has visited.
@@ -888,7 +925,7 @@ (defun Info-find-node (filename nodename
   ;; Record the node we are leaving, if we were in one.
   (and (not no-going-back)
        Info-current-file
-       (push (list Info-current-file Info-current-node (point))
+       (push (list Info-current-file Info-current-node (point) (window-start))
              Info-history))
   (Info-find-node-2 filename nodename no-going-back))
 
@@ -922,7 +959,7 @@ (defun Info-revert-find-node (filename n
 	(pline        (count-lines (point-min) (line-beginning-position)))
 	(wline        (count-lines (point-min) (window-start)))
 	(new-history  (and Info-current-file
-			   (list Info-current-file Info-current-node (point)))))
+			   (list Info-current-file Info-current-node (point) (window-start)))))
     ;; When `Info-current-file' is nil, `Info-find-node-2' rereads the file.
     (setq Info-current-file nil)
     (Info-find-node filename nodename)
@@ -1192,7 +1229,8 @@ (defun Info-find-node-2 (filename nodena
         (let ((hist (car Info-history)))
           (setq Info-history (cdr Info-history))
           (Info-find-node (nth 0 hist) (nth 1 hist) t)
-          (goto-char (nth 2 hist))))))
+          (goto-char (nth 2 hist))
+	  (set-window-start (selected-window) (nth 3 hist))))))
 
 ;; Cache the contents of the (virtual) dir file, once we have merged
 ;; it for the first time, so we can save time subsequently.
@@ -1968,7 +2008,7 @@ (defun Info-search (regexp &optional bou
 	       (equal ofile Info-current-file))
           (and isearch-mode isearch-wrapped
 	       (eq opoint (if isearch-forward opoint-min opoint-max)))
-	  (setq Info-history (cons (list ofile onode opoint)
+	  (setq Info-history (cons (list ofile onode opoint ostart)
 				   Info-history))))))
 
 (defun Info-search-case-sensitively ()
@@ -2174,17 +2214,19 @@ (defun Info-history-back ()
   (or Info-history
       (user-error "This is the first Info node you looked at"))
   (let ((history-forward
-	 (cons (list Info-current-file Info-current-node (point))
+	 (cons (list Info-current-file Info-current-node (point) (window-start))
 	       Info-history-forward))
-	filename nodename opoint)
+	filename nodename opoint ostart)
     (setq filename (car (car Info-history)))
     (setq nodename (car (cdr (car Info-history))))
     (setq opoint (car (cdr (cdr (car Info-history)))))
+    (setq ostart (car (cdr (cdr (cdr (car Info-history))))))
     (setq Info-history (cdr Info-history))
     (Info-find-node filename nodename)
     (setq Info-history (cdr Info-history))
     (setq Info-history-forward history-forward)
-    (goto-char opoint)))
+    (goto-char opoint)
+    (set-window-start (selected-window) ostart)))
 
 (defalias 'Info-last 'Info-history-back)
 
@@ -2194,13 +2236,15 @@ (defun Info-history-forward ()
   (or Info-history-forward
       (user-error "This is the last Info node you looked at"))
   (let ((history-forward (cdr Info-history-forward))
-	filename nodename opoint)
+	filename nodename opoint ostart)
     (setq filename (car (car Info-history-forward)))
     (setq nodename (car (cdr (car Info-history-forward))))
     (setq opoint (car (cdr (cdr (car Info-history-forward)))))
+    (setq ostart (car (cdr (cdr (cdr (car Info-history-forward))))))
     (Info-find-node filename nodename)
     (setq Info-history-forward history-forward)
-    (goto-char opoint)))
+    (goto-char opoint)
+    (set-window-start (selected-window) ostart)))
 \f
 (add-to-list 'Info-virtual-files
 	     '("\\`dir\\'"






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#12230: 24.2; revert-buffer in an Info buffer should refresh Info-index-nodes
  2012-08-21  0:15         ` Juri Linkov
@ 2012-08-21  6:15           ` Chong Yidong
  2012-08-21 22:24             ` Juri Linkov
  2012-08-21  6:49           ` martin rudalics
  1 sibling, 1 reply; 9+ messages in thread
From: Chong Yidong @ 2012-08-21  6:15 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 12230

Juri Linkov <juri@jurta.org> writes:

> Installed with cache invalidation for `Info-index-nodes' and
> `Info-toc-nodes' (I had to put code to `info-insert-file-contents'
> instead of `Info-find-file' because the full filename is available
> only in the former).

Thanks.  If this bug is fixed, please close it in the tracker.

> BTW, let me use this opportunity to propose an improvement that restores
> the original window point when returning back to the previous node.
> This helps to avoid distraction when point jumps from the original
> window position (displayed before leaving the Info node) to
> another position (by default, center of the window):

Looks fine by me.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#12230: 24.2; revert-buffer in an Info buffer should refresh Info-index-nodes
  2012-08-21  0:15         ` Juri Linkov
  2012-08-21  6:15           ` Chong Yidong
@ 2012-08-21  6:49           ` martin rudalics
  1 sibling, 0 replies; 9+ messages in thread
From: martin rudalics @ 2012-08-21  6:49 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 12230

 > +	  (set-window-start (selected-window) (nth 3 hist))))))
[...]
 > +    (set-window-start (selected-window) ostart)))
[...]
 > +    (set-window-start (selected-window) ostart)))

Are you sure you want to force start positions here?

martin





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#12230: 24.2; revert-buffer in an Info buffer should refresh Info-index-nodes
  2012-08-21  6:15           ` Chong Yidong
@ 2012-08-21 22:24             ` Juri Linkov
  0 siblings, 0 replies; 9+ messages in thread
From: Juri Linkov @ 2012-08-21 22:24 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 12230-done

> Thanks.  If this bug is fixed, please close it in the tracker.

Closed.  A new request is created in bug#12253.





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-08-21 22:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-18 18:15 bug#12230: 24.2; revert-buffer in an Info buffer should refresh Info-index-nodes Eli Zaretskii
2012-08-18 22:31 ` Juri Linkov
2012-08-19  2:48   ` Eli Zaretskii
2012-08-19 23:39     ` Juri Linkov
2012-08-20  2:45       ` Eli Zaretskii
2012-08-21  0:15         ` Juri Linkov
2012-08-21  6:15           ` Chong Yidong
2012-08-21 22:24             ` Juri Linkov
2012-08-21  6:49           ` martin rudalics

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