From ce0fcefa27728a4e83e10962075c388c8a6da87a Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 8 Aug 2012 11:48:57 +0300 Subject: [PATCH] * lisp/bookmark.el: Add `defaults' property to the bookmark record. (bookmark-current-buffer): Doc fix. (bookmark-make-record): Add `defaults' property with default values to the bookmark record. (bookmark-minibuffer-read-name-map): Remove key binding "\C-u" with `bookmark-insert-current-bookmark'. (bookmark-set): Get `defaults' property from the bookmark record and use it in `read-from-minibuffer'. (bookmark-insert-current-bookmark): Remove function. * lisp/info.el (Info-bookmark-make-record): Add `defaults' property with values of canonical Info node name, the current Info file name and the current Info node name. Fixes: debbugs:12107 --- lisp/ChangeLog | 16 ++++++++++++++++ lisp/bookmark.el | 42 ++++++++++++++++++++++-------------------- lisp/info.el | 17 ++++++++++++----- 3 files changed, 50 insertions(+), 25 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 00cbe9f36e..f199102295 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,19 @@ +2012-08-08 Juri Linkov + + * bookmark.el: Add `defaults' property to the bookmark record. + (bookmark-current-buffer): Doc fix. + (bookmark-make-record): Add `defaults' property with default values + to the bookmark record. + (bookmark-minibuffer-read-name-map): Remove key binding "\C-u" + with `bookmark-insert-current-bookmark'. + (bookmark-set): Get `defaults' property from the bookmark record + and use it in `read-from-minibuffer'. + (bookmark-insert-current-bookmark): Remove function. + + * info.el (Info-bookmark-make-record): Add `defaults' property + with values of canonical Info node name, the current Info file + name and the current Info node name. (Bug#12107) + 2012-08-08 Juri Linkov * files.el (basic-save-buffer): Use `buffer-name' as the default diff --git a/lisp/bookmark.el b/lisp/bookmark.el index 8e6fb94c0d..75a8d9f59d 100644 --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -277,8 +277,8 @@ through a file easier.") (defvar bookmark-current-buffer nil "The buffer in which a bookmark is currently being set or renamed. Functions that insert strings into the minibuffer use this to know -the source buffer for that information; see `bookmark-yank-word' and -`bookmark-insert-current-bookmark' for example.") +the source buffer for that information; see `bookmark-yank-word' +for example.") (defvar bookmark-yank-point 0 @@ -473,6 +473,12 @@ equivalently just return ALIST without NAME.") (defun bookmark-make-record () "Return a new bookmark record (NAME . ALIST) for the current location." (let ((record (funcall bookmark-make-record-function))) + ;; Set up defaults. + (bookmark-prop-set + record 'defaults + (delq nil (delete-dups (append (bookmark-prop-get record 'defaults) + (list bookmark-current-bookmark + (bookmark-buffer-name)))))) ;; Set up default name. (if (stringp (car record)) ;; The function already provided a default name. @@ -738,10 +744,6 @@ This expects to be called from `point-min' in a bookmark file." (let ((map (make-sparse-keymap))) (set-keymap-parent map minibuffer-local-map) (define-key map "\C-w" 'bookmark-yank-word) - ;; This C-u binding might not be very useful any more now that we - ;; provide access to the default via the standard M-n binding. - ;; Maybe we should just remove it? --Stef-08 - (define-key map "\C-u" 'bookmark-insert-current-bookmark) map)) ;;;###autoload @@ -772,7 +774,19 @@ the list of bookmarks.)" (interactive (list nil current-prefix-arg)) (unwind-protect (let* ((record (bookmark-make-record)) - (default (car record))) + ;; `defaults' is a transient element of the + ;; extensible format described above in the section + ;; `File format stuff'. Bookmark record functions + ;; can use it to specify a list of default values + ;; accessible via M-n while reading a bookmark name. + (defaults (bookmark-prop-get record 'defaults)) + (default (if (consp defaults) (car defaults) defaults))) + + (if defaults + ;; Don't store default values in the record. + (setq record (assq-delete-all 'defaults record)) + ;; When no defaults in the record, use its first element. + (setq defaults (car record) default defaults)) (bookmark-maybe-load-default-file) ;; Don't set `bookmark-yank-point' and `bookmark-current-buffer' @@ -788,7 +802,7 @@ the list of bookmarks.)" (format "Set bookmark (%s): " default) nil bookmark-minibuffer-read-name-map - nil nil default)))) + nil nil defaults)))) (and (string-equal str "") (setq str default)) (bookmark-store str (cdr record) no-overwrite) @@ -888,18 +902,6 @@ Lines beginning with `#' are ignored." (bookmark-edit-annotation-mode bookmark-name-or-record)) -(defun bookmark-insert-current-bookmark () - "Insert into the bookmark name currently being set the value of -`bookmark-current-bookmark' in `bookmark-current-buffer', defaulting -to the buffer's file name if `bookmark-current-bookmark' is nil." - (interactive) - (let ((str - (with-current-buffer bookmark-current-buffer - (or bookmark-current-bookmark - (bookmark-buffer-name))))) - (insert str))) - - (defun bookmark-buffer-name () "Return the name of the current buffer in a form usable as a bookmark name. If the buffer is associated with a file or directory, use that name." diff --git a/lisp/info.el b/lisp/info.el index 93046bd13d..317cba8650 100644 --- a/lisp/info.el +++ b/lisp/info.el @@ -5020,11 +5020,18 @@ BUFFER is the buffer speedbar is requesting buttons for." (defun Info-bookmark-make-record () "This implements the `bookmark-make-record-function' type (which see) for Info nodes." - `(,Info-current-node - ,@(bookmark-make-record-default 'no-file) - (filename . ,Info-current-file) - (info-node . ,Info-current-node) - (handler . Info-bookmark-jump))) + (let* ((file (and (stringp Info-current-file) + (file-name-nondirectory Info-current-file))) + (bookmark-name (if file + (concat "(" file ") " Info-current-node) + Info-current-node)) + (defaults (delq nil (list bookmark-name file Info-current-node)))) + `(,bookmark-name + ,@(bookmark-make-record-default 'no-file) + (filename . ,Info-current-file) + (info-node . ,Info-current-node) + (handler . Info-bookmark-jump) + (defaults . ,defaults)))) ;;;###autoload (defun Info-bookmark-jump (bmk) -- 2.20.1