From: Karl Fogel <kfogel@floss.red-bean.com>
Cc: emacs-devel@gnu.org
Subject: Re: enhancement to bookmark.el
Date: 12 Jun 2004 14:43:23 -0500 [thread overview]
Message-ID: <87isdwbm04.fsf@floss.red-bean.com> (raw)
"David J. Biesack" <David.Biesack@sas.com> writes:
> I have an enhancement request for bookmark.el.
>
> Bookmark's menu mode does not have a key/command for moving the file.
> The below adds this, as well as an interactive bookmark-move command.
> I'm not particularly happy with the key binding, but 'm' (for 'move)
> and 'r' (rename0 are already taken.
Thank you! It seems like a good enhancement; I've committed it to
Emacs, though using somewhat different code.
I called the new bmenu function `bookmark-bmenu-relocate', and bound
it to "R", not "M".
Aside from the renaming, I rewrote the function to document what it
does better, and to use `bookmark-relocate' instead of writing
equivalent code. (Your comment indicated that you thought
bookmark-relocate only prompts for the directory. In fact, it prompts
for a new file -- the directory is just the default base string for
the completion).
I didn't include the new function `bookmark-move' at all, since we
have `bookmark-relocate'. If `bookmark-relocate' is missing some
functionality, let's just try to fix it there, no need to add a new
function.
Below is the patch I committed. Note the doc string updates, the
binding of the new function in the same place as the other bindings,
and the factorization of the bookmark-alist save checking. Following
the patch is your original mail, for easy comparison.
Best,
-Karl Fogel
Index: ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.6147
diff -u -r1.6147 ChangeLog
--- ChangeLog 8 Jun 2004 00:35:48 -0000 1.6147
+++ ChangeLog 13 Jun 2004 01:54:38 -0000
@@ -1,3 +1,11 @@
+2004-06-12 Karl Fogel <kfogel@red-bean.com>
+
+ * bookmark.el (bookmark-bmenu-relocate): New function, as
+ suggested by David J. Biesack <David.Biesack@sas.com>.
+ (bookmark-bmenu-mode-map): Bind `bookmark-bmenu-relocate' to "R".
+ (bookmark-bmenu-mode): Describe binding in doc string.
+ (bookmark-set-filename): Save the bookmark list if it's time.
+
2004-06-07 Karl Fogel <kfogel@red-bean.com>
* saveplace.el (save-place-alist-to-file): Bind `print-length'
Index: bookmark.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/bookmark.el,v
retrieving revision 1.68
diff -u -r1.68 bookmark.el
--- bookmark.el 15 Apr 2004 23:12:21 -0000 1.68
+++ bookmark.el 13 Jun 2004 01:54:40 -0000
@@ -376,7 +376,11 @@
(if cell
(setcdr cell filename)
(nconc (bookmark-get-bookmark-record bookmark)
- (list (cons 'filename filename))))))
+ (list (cons 'filename filename))))
+ (setq bookmark-alist-modification-count
+ (1+ bookmark-alist-modification-count))
+ (if (bookmark-time-to-save-p)
+ (bookmark-save))))
(defun bookmark-get-position (bookmark)
@@ -1491,6 +1495,7 @@
(define-key bookmark-bmenu-mode-map "m" 'bookmark-bmenu-mark)
(define-key bookmark-bmenu-mode-map "l" 'bookmark-bmenu-load)
(define-key bookmark-bmenu-mode-map "r" 'bookmark-bmenu-rename)
+ (define-key bookmark-bmenu-mode-map "R" 'bookmark-bmenu-relocate)
(define-key bookmark-bmenu-mode-map "t" 'bookmark-bmenu-toggle-filenames)
(define-key bookmark-bmenu-mode-map "a" 'bookmark-bmenu-show-annotation)
(define-key bookmark-bmenu-mode-map "A" 'bookmark-bmenu-show-all-annotations)
@@ -1589,6 +1594,7 @@
so the bookmark menu bookmark remains visible in its window.
\\[bookmark-bmenu-switch-other-window] -- switch the other window to this bookmark.
\\[bookmark-bmenu-rename] -- rename this bookmark \(prompts for new name\).
+\\[bookmark-bmenu-relocate] -- relocate this bookmark's file \(prompts for new file\).
\\[bookmark-bmenu-delete] -- mark this bookmark to be deleted, and move down.
\\[bookmark-bmenu-delete-backwards] -- mark this bookmark to be deleted, and move up.
\\[bookmark-bmenu-execute-deletions] -- delete bookmarks marked with `\\[bookmark-bmenu-delete]'.
@@ -2041,6 +2047,15 @@
(let ((bmrk (bookmark-bmenu-bookmark)))
(message (bookmark-location bmrk)))))
+(defun bookmark-bmenu-relocate ()
+ "Change the file path of the bookmark on the current line,
+ prompting with completion for the new path."
+ (interactive)
+ (if (bookmark-bmenu-check-position)
+ (let ((bmrk (bookmark-bmenu-bookmark))
+ (thispoint (point)))
+ (bookmark-relocate bmrk)
+ (goto-char thispoint))))
\f
;;; Menu bar stuff. Prefix is "bookmark-menu".
########################################################################
And your original mail:
########################################################################
> From: "David J. Biesack" <David.Biesack@sas.com>
> Subject: enhancement to bookmark.el
> To: bug-gnu-emacs@gnu.org
> Date: Tue, 8 Jun 2004 16:33:46 -0400 (EDT)
>
>
> I have an enhancement request for bookmark.el.
>
> Bookmark's menu mode does not have a key/command for moving the file.
> The below adds this, as well as an interactive bookmark-move command.
> I'm not particularly happy with the key binding, but 'm' (for 'move)
> and 'r' (rename0 are already taken.
>
> ;; Add a "Move" action to bookmark-bmenu, to move a bookmark to a new file
> ;; David.Biesack@sas.com
>
> (defun bookmark-bmenu-move ()
> "Move bookmark on current line. Prompts for a new filename."
> (interactive)
> (if (bookmark-bmenu-check-position)
> (let ((bmrk (bookmark-bmenu-bookmark))
> (thispoint (point)))
> ;; could also invoke
> ;(bookmark-relocate bmrk)
> ;; but that only prompts for the directory name; sometimes
> ;; bookmarked file names change as well.
> (bookmark-move bmrk)
> (bookmark-bmenu-list)
> (goto-char thispoint))))
>
> (defun bookmark-move (name &optional to)
> (interactive (bookmark-completing-read "Move bookmark: "))
> (bookmark-maybe-load-default-file)
>
> (setq bookmark-current-point (point))
> (setq bookmark-yank-point (point))
> (setq bookmark-current-buffer (current-buffer))
> (let ((newname
> (or to ; use second arg, if non-nil
> (read-from-minibuffer
> "Move to: "
> (bookmark-get-filename name)
> (let ((now-map (copy-keymap minibuffer-local-map)))
> (define-key now-map "\C-w" 'bookmark-yank-word)
> now-map)
> nil
> 'bookmark-history))))
> (bookmark-set-filename name newname)
> (setq bookmark-current-bookmark name)
> (bookmark-bmenu-surreptitiously-rebuild-list)
> (setq bookmark-alist-modification-count
> (1+ bookmark-alist-modification-count))
> (if (bookmark-time-to-save-p)
> (bookmark-save))))
>
> (define-key bookmark-bmenu-mode-map "M" 'bookmark-bmenu-move)
>
>
>
> - --
> David J. Biesack SAS Institute Inc.
> R&D Java Strategist SAS Campus Drive Cary, NC 27513
> (919) 531-7771 http://www.sas.com
next reply other threads:[~2004-06-12 19:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-12 19:43 Karl Fogel [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-06-08 20:33 enhancement to bookmark.el David J. Biesack
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=87isdwbm04.fsf@floss.red-bean.com \
--to=kfogel@floss.red-bean.com \
--cc=emacs-devel@gnu.org \
--cc=kfogel@red-bean.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 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.