unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Boruch Baum <boruch_baum@gmx.com>
Cc: 20150@debbugs.gnu.org
Subject: bug#20150: 24.4: bookmarks: return from editing annotations (FIX INCLUDED)
Date: Tue, 2 Jul 2019 05:23:59 +0200	[thread overview]
Message-ID: <CADwFkm=kAb6-ZNGZbvLGG_SYQfLfdNBTMd348_LSBn8HN0Zz0g@mail.gmail.com> (raw)
In-Reply-To: <CADwFkmmxN+3w67FPvToMsyKj4=u9cxALYWv9U2YmHCA8-uYqZQ@mail.gmail.com>

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

Stefan Kangas <stefan@marxist.se> writes:
> > When completing a bookmark annotation edit, the point on the bmenu-list
> > would move to point-max and the selected window would be wherever the
> > annotation buffer had been displayed.
>
> I can confirm this bug, and suggest the attached fix.

Please see this somewhat improved patch instead.

Thanks,
Stefan Kangas

[-- Attachment #2: 0001-Restore-focus-to-Bookmark-List-after-editing-annotat-2.patch --]
[-- Type: application/octet-stream, Size: 3386 bytes --]

From feb894ae1016c2a0735b58f0dabf11e5f750d75b Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Tue, 2 Jul 2019 03:06:37 +0200
Subject: [PATCH] Restore focus to Bookmark List after editing annotation

* lisp/bookmark.el (bookmark-send-edited-annotation): Restore focus to
Bookmark List after editing the annotation.  Also take care to delete
window when needed, and move point back to bookmark. (Bug#20150)

(bookmark-annotation-name): Improve docstring.
(bookmark-bmenu-buffer): New variable.
(bookmark-bmenu-surreptitiously-rebuild-list)
(bookmark-bmenu-list): Use it.
---
 lisp/bookmark.el | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index bbef0a927d..faf7d5696e 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -900,11 +900,9 @@ bookmark-kill-line
       (delete-char 1))))
 
 
-;; Defvars to avoid compilation warnings:
 (defvar bookmark-annotation-name nil
-  "Variable holding the name of the bookmark.
-This is used in `bookmark-edit-annotation' to record the bookmark
-whose annotation is being edited.")
+  "Name of bookmark whose annotation is being edited.
+This is used by `bookmark-edit-annotation-mode'.")
 
 
 (defun bookmark-default-annotation-text (bookmark-name)
@@ -963,12 +961,19 @@ bookmark-send-edited-annotation
       (forward-line 1)))
   ;; Take no chances with text properties.
   (let ((annotation (buffer-substring-no-properties (point-min) (point-max)))
-	(bookmark-name bookmark-annotation-name))
+        (bookmark-name bookmark-annotation-name)
+        (old-buffer (current-buffer)))
     (bookmark-set-annotation bookmark-name annotation)
     (setq bookmark-alist-modification-count
           (1+ bookmark-alist-modification-count))
-    (bookmark-bmenu-surreptitiously-rebuild-list))
-  (kill-buffer (current-buffer)))
+    (quit-window)
+    (pop-to-buffer (get-buffer bookmark-bmenu-buffer))
+    (bookmark-bmenu-list)
+    (goto-char (point-min))
+    (unless (text-property-search-forward 'bookmark-name-prop bookmark-name)
+      (goto-char (point-min)))
+    (message "Set annotation for \"%s\"" bookmark-name)
+    (kill-buffer old-buffer)))
 
 
 (defun bookmark-edit-annotation (bookmark-name-or-record)
@@ -1563,9 +1568,11 @@ bookmark-load
 	(progress-reporter-done reporter)))))
 
 \f
-;;; Code supporting the dired-like bookmark menu.
+;;; Code supporting the dired-like bookmark list.
 ;; Prefix is "bookmark-bmenu" for "buffer-menu":
 
+(defconst bookmark-bmenu-buffer "*Bookmark List*"
+  "Name of buffer used for Bookmark List.")
 
 (defvar bookmark-bmenu-hidden-bookmarks ())
 
@@ -1650,7 +1657,7 @@ bookmark-bmenu-mode-map
 (defun bookmark-bmenu-surreptitiously-rebuild-list ()
   "Rebuild the Bookmark List if it exists.
 Don't affect the buffer ring order."
-  (if (get-buffer "*Bookmark List*")
+  (if (get-buffer bookmark-bmenu-buffer)
       (save-excursion
         (save-window-excursion
           (bookmark-bmenu-list)))))
@@ -1664,7 +1671,7 @@ bookmark-bmenu-list
 deletion, or > if it is flagged for displaying."
   (interactive)
   (bookmark-maybe-load-default-file)
-  (let ((buf (get-buffer-create "*Bookmark List*")))
+  (let ((buf (get-buffer-create bookmark-bmenu-buffer)))
     (if (called-interactively-p 'interactive)
         (switch-to-buffer buf)
       (set-buffer buf)))
-- 
2.21.0


  reply	other threads:[~2019-07-02  3:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20  7:24 bug#20150: 24.4: bookmarks: return from editing annotations (FIX INCLUDED) Boruch Baum
2015-03-20 14:28 ` Stefan Monnier
2015-03-20 16:22   ` Boruch Baum
2019-07-02  1:54 ` Stefan Kangas
2019-07-02  3:23   ` Stefan Kangas [this message]
2019-07-03 20:05     ` Stefan Kangas
2019-07-04 19:20       ` Stefan Kangas
2019-07-04 19:40         ` Stefan Kangas
2019-07-13  7:30           ` Eli Zaretskii
2019-07-13 13:09             ` Stefan Kangas
2019-07-13 13:24               ` Eli Zaretskii
2019-07-13 13:51                 ` Stefan Kangas
2019-07-14  1:48                   ` Glenn Morris
2019-07-14  6:04                     ` Eli Zaretskii
2019-07-14  6:29               ` Eli Zaretskii

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='CADwFkm=kAb6-ZNGZbvLGG_SYQfLfdNBTMd348_LSBn8HN0Zz0g@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=20150@debbugs.gnu.org \
    --cc=boruch_baum@gmx.com \
    /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 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).