aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2012-08-08 11:48:57 +0300
committerJuri Linkov2012-08-08 11:48:57 +0300
commitce0fcefa27728a4e83e10962075c388c8a6da87a (patch)
tree5b5d479c062b457950a84f707b3333693d079993
parent53fa865294bada6c2c441f195211671d427bcd69 (diff)
downloademacs-ce0fcefa27728a4e83e10962075c388c8a6da87a.tar.gz
emacs-ce0fcefa27728a4e83e10962075c388c8a6da87a.zip
* 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
-rw-r--r--lisp/ChangeLog16
-rw-r--r--lisp/bookmark.el42
-rw-r--r--lisp/info.el17
3 files changed, 50 insertions, 25 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 00cbe9f36ee..f199102295a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,21 @@
12012-08-08 Juri Linkov <juri@jurta.org> 12012-08-08 Juri Linkov <juri@jurta.org>
2 2
3 * bookmark.el: Add `defaults' property to the bookmark record.
4 (bookmark-current-buffer): Doc fix.
5 (bookmark-make-record): Add `defaults' property with default values
6 to the bookmark record.
7 (bookmark-minibuffer-read-name-map): Remove key binding "\C-u"
8 with `bookmark-insert-current-bookmark'.
9 (bookmark-set): Get `defaults' property from the bookmark record
10 and use it in `read-from-minibuffer'.
11 (bookmark-insert-current-bookmark): Remove function.
12
13 * info.el (Info-bookmark-make-record): Add `defaults' property
14 with values of canonical Info node name, the current Info file
15 name and the current Info node name. (Bug#12107)
16
172012-08-08 Juri Linkov <juri@jurta.org>
18
3 * files.el (basic-save-buffer): Use `buffer-name' as the default 19 * files.el (basic-save-buffer): Use `buffer-name' as the default
4 of `read-file-name' when buffer is not visiting a file (bug#12128). 20 of `read-file-name' when buffer is not visiting a file (bug#12128).
5 21
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 8e6fb94c0dd..75a8d9f59dc 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -277,8 +277,8 @@ through a file easier.")
277(defvar bookmark-current-buffer nil 277(defvar bookmark-current-buffer nil
278 "The buffer in which a bookmark is currently being set or renamed. 278 "The buffer in which a bookmark is currently being set or renamed.
279Functions that insert strings into the minibuffer use this to know 279Functions that insert strings into the minibuffer use this to know
280the source buffer for that information; see `bookmark-yank-word' and 280the source buffer for that information; see `bookmark-yank-word'
281`bookmark-insert-current-bookmark' for example.") 281for example.")
282 282
283 283
284(defvar bookmark-yank-point 0 284(defvar bookmark-yank-point 0
@@ -473,6 +473,12 @@ equivalently just return ALIST without NAME.")
473(defun bookmark-make-record () 473(defun bookmark-make-record ()
474 "Return a new bookmark record (NAME . ALIST) for the current location." 474 "Return a new bookmark record (NAME . ALIST) for the current location."
475 (let ((record (funcall bookmark-make-record-function))) 475 (let ((record (funcall bookmark-make-record-function)))
476 ;; Set up defaults.
477 (bookmark-prop-set
478 record 'defaults
479 (delq nil (delete-dups (append (bookmark-prop-get record 'defaults)
480 (list bookmark-current-bookmark
481 (bookmark-buffer-name))))))
476 ;; Set up default name. 482 ;; Set up default name.
477 (if (stringp (car record)) 483 (if (stringp (car record))
478 ;; The function already provided a default name. 484 ;; The function already provided a default name.
@@ -738,10 +744,6 @@ This expects to be called from `point-min' in a bookmark file."
738 (let ((map (make-sparse-keymap))) 744 (let ((map (make-sparse-keymap)))
739 (set-keymap-parent map minibuffer-local-map) 745 (set-keymap-parent map minibuffer-local-map)
740 (define-key map "\C-w" 'bookmark-yank-word) 746 (define-key map "\C-w" 'bookmark-yank-word)
741 ;; This C-u binding might not be very useful any more now that we
742 ;; provide access to the default via the standard M-n binding.
743 ;; Maybe we should just remove it? --Stef-08
744 (define-key map "\C-u" 'bookmark-insert-current-bookmark)
745 map)) 747 map))
746 748
747;;;###autoload 749;;;###autoload
@@ -772,7 +774,19 @@ the list of bookmarks.)"
772 (interactive (list nil current-prefix-arg)) 774 (interactive (list nil current-prefix-arg))
773 (unwind-protect 775 (unwind-protect
774 (let* ((record (bookmark-make-record)) 776 (let* ((record (bookmark-make-record))
775 (default (car record))) 777 ;; `defaults' is a transient element of the
778 ;; extensible format described above in the section
779 ;; `File format stuff'. Bookmark record functions
780 ;; can use it to specify a list of default values
781 ;; accessible via M-n while reading a bookmark name.
782 (defaults (bookmark-prop-get record 'defaults))
783 (default (if (consp defaults) (car defaults) defaults)))
784
785 (if defaults
786 ;; Don't store default values in the record.
787 (setq record (assq-delete-all 'defaults record))
788 ;; When no defaults in the record, use its first element.
789 (setq defaults (car record) default defaults))
776 790
777 (bookmark-maybe-load-default-file) 791 (bookmark-maybe-load-default-file)
778 ;; Don't set `bookmark-yank-point' and `bookmark-current-buffer' 792 ;; Don't set `bookmark-yank-point' and `bookmark-current-buffer'
@@ -788,7 +802,7 @@ the list of bookmarks.)"
788 (format "Set bookmark (%s): " default) 802 (format "Set bookmark (%s): " default)
789 nil 803 nil
790 bookmark-minibuffer-read-name-map 804 bookmark-minibuffer-read-name-map
791 nil nil default)))) 805 nil nil defaults))))
792 (and (string-equal str "") (setq str default)) 806 (and (string-equal str "") (setq str default))
793 (bookmark-store str (cdr record) no-overwrite) 807 (bookmark-store str (cdr record) no-overwrite)
794 808
@@ -888,18 +902,6 @@ Lines beginning with `#' are ignored."
888 (bookmark-edit-annotation-mode bookmark-name-or-record)) 902 (bookmark-edit-annotation-mode bookmark-name-or-record))
889 903
890 904
891(defun bookmark-insert-current-bookmark ()
892 "Insert into the bookmark name currently being set the value of
893`bookmark-current-bookmark' in `bookmark-current-buffer', defaulting
894to the buffer's file name if `bookmark-current-bookmark' is nil."
895 (interactive)
896 (let ((str
897 (with-current-buffer bookmark-current-buffer
898 (or bookmark-current-bookmark
899 (bookmark-buffer-name)))))
900 (insert str)))
901
902
903(defun bookmark-buffer-name () 905(defun bookmark-buffer-name ()
904 "Return the name of the current buffer in a form usable as a bookmark name. 906 "Return the name of the current buffer in a form usable as a bookmark name.
905If the buffer is associated with a file or directory, use that name." 907If the buffer is associated with a file or directory, use that name."
diff --git a/lisp/info.el b/lisp/info.el
index 93046bd13d6..317cba86500 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -5020,11 +5020,18 @@ BUFFER is the buffer speedbar is requesting buttons for."
5020(defun Info-bookmark-make-record () 5020(defun Info-bookmark-make-record ()
5021 "This implements the `bookmark-make-record-function' type (which see) 5021 "This implements the `bookmark-make-record-function' type (which see)
5022for Info nodes." 5022for Info nodes."
5023 `(,Info-current-node 5023 (let* ((file (and (stringp Info-current-file)
5024 ,@(bookmark-make-record-default 'no-file) 5024 (file-name-nondirectory Info-current-file)))
5025 (filename . ,Info-current-file) 5025 (bookmark-name (if file
5026 (info-node . ,Info-current-node) 5026 (concat "(" file ") " Info-current-node)
5027 (handler . Info-bookmark-jump))) 5027 Info-current-node))
5028 (defaults (delq nil (list bookmark-name file Info-current-node))))
5029 `(,bookmark-name
5030 ,@(bookmark-make-record-default 'no-file)
5031 (filename . ,Info-current-file)
5032 (info-node . ,Info-current-node)
5033 (handler . Info-bookmark-jump)
5034 (defaults . ,defaults))))
5028 5035
5029;;;###autoload 5036;;;###autoload
5030(defun Info-bookmark-jump (bmk) 5037(defun Info-bookmark-jump (bmk)