bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#22332: 25.0.50; woman moves point in a wrong buffer


From: Kaushal Modi
Subject: bug#22332: 25.0.50; woman moves point in a wrong buffer
Date: Sat, 9 Jan 2016 17:32:23 -0500

Here's a more complicated version of the fix (patch explanation in the patch itself):

From 99732dfad7eff097948302f9cc1a4adec3c55504 Mon Sep 17 00:00:00 2001
From: Kaushal Modi <address@hidden>
Date: Sat, 9 Jan 2016 17:27:43 -0500
Subject: [PATCH] Ensure point manipulation only in WoMan buf

- WoMan-find-buffer definition is changed; now it only returns the WoMan
  buffer, does not switch to it. Bug fix: return the WoMan buffer name
  instead of the window name.
- woman-find-file is fixed (bug # 22332) so that now the point
  manipulation happens only in the WoMan buffer.
---
 lisp/woman.el | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/lisp/woman.el b/lisp/woman.el
index 4ca7dbe..0d2f5f4 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -1598,13 +1598,17 @@ woman-find-file
   (interactive "fBrowse UN*X manual file: \nP")
   (setq woman-last-file-name
  (setq file-name (expand-file-name file-name))) ; to canonicalize
-  (let ((alist-tail woman-buffer-alist) exists)
+  (let ((alist-tail woman-buffer-alist)
+        woman-buffer
+        exists)
     (setq woman-buffer-number 0)
     (while (and alist-tail (not (string= file-name (car (car alist-tail)))))
       (setq alist-tail (cdr alist-tail)
     woman-buffer-number (1+ woman-buffer-number)))
-    (or (and (setq exists
-   (and alist-tail (WoMan-find-buffer))) ; buffer exists
+    (when alist-tail
+      (setq woman-buffer (WoMan-find-buffer)))
+    (setq exists (and alist-tail woman-buffer))
+    (or (and exists ; buffer exists
      (not reformat))
  ;; Format new buffer or reformat current buffer:
  (let* ((bufname (file-name-nondirectory file-name))
@@ -1620,10 +1624,12 @@ woman-find-file
   (or exists
       (setq woman-buffer-alist
     (cons (cons file-name bufname) woman-buffer-alist)
-    woman-buffer-number 0)))))
-  (Man-build-section-alist)
-  (Man-build-references-alist)
-  (goto-char (point-min)))
+    woman-buffer-number 0))))
+    (when woman-buffer
+      (with-current-buffer (get-buffer woman-buffer)
+        (Man-build-section-alist)
+        (Man-build-references-alist)
+        (goto-char (point-min))))))
 
 (defun woman-make-bufname (bufname)
   "Create an unambiguous buffer name from BUFNAME."
@@ -2055,20 +2061,24 @@ WoMan-next-manpage
     (WoMan-next-manpage)))
 
 (defun WoMan-find-buffer ()
-  "Switch to buffer corresponding to `woman-buffer-number' and return it.
+  "Return the buffer corresponding to `woman-buffer-number'.
 If such a buffer does not exist then remove its association from the
 alist in `woman-buffer-alist' and return nil."
   (if (zerop woman-buffer-number)
       (let ((buffer (get-buffer (cdr (car woman-buffer-alist)))))
  (if buffer
-    (display-buffer buffer)
+            (progn
+              (display-buffer buffer)
+              buffer)
   ;; Delete alist element:
   (setq woman-buffer-alist (cdr woman-buffer-alist))
   nil))
     (let* ((prev-ptr (nthcdr (1- woman-buffer-number) woman-buffer-alist))
    (buffer (get-buffer (cdr (car (cdr prev-ptr))))))
       (if buffer
-  (display-buffer buffer)
+          (progn
+            (display-buffer buffer)
+            buffer)
  ;; Delete alist element:
  (setcdr prev-ptr (cdr (cdr prev-ptr)))
  (if (>= woman-buffer-number (length woman-buffer-alist))
-- 
2.6.0.rc0.24.gec371ff



--
Kaushal Modi

On Sat, Jan 9, 2016 at 12:42 PM, martin rudalics <address@hidden> wrote:
> Perhaps calls to display-buffer can be replaced with calls to
> pop-to-buffer in defun WoMan-find-buffer?

I don't think so.  By default the buffer should be displayed in the
selected window and ‘pop-to-buffer’ is supposed to "Select buffer BUFFER
in some window, preferably a different one."

martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]