unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* enhancement to bookmark.el
@ 2004-06-08 20:33 David J. Biesack
  0 siblings, 0 replies; only message in thread
From: David J. Biesack @ 2004-06-08 20:33 UTC (permalink / raw)



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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-06-08 20:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-08 20:33 enhancement to bookmark.el David J. Biesack

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