aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-03-11 20:17:37 +0000
committerRichard M. Stallman1995-03-11 20:17:37 +0000
commit4cd51172ca923cf882dc951319fbd5806f34031f (patch)
tree44f686127c5759d2fcea1cd7c38e09feec392668
parent3f299281ab364f4b267e328635186cc5a3bbcb8c (diff)
downloademacs-4cd51172ca923cf882dc951319fbd5806f34031f.tar.gz
emacs-4cd51172ca923cf882dc951319fbd5806f34031f.zip
(bookmark-buffer-name): Be smarter about deducing a name.
(bookmark-insert-buffer-name): Use bookmark-buffer-name. Replaces bookmark-insert-current-file-name. (bookmark-make-cell): Use set-text-properties, not format, to clear text properties.
-rw-r--r--lisp/bookmark.el63
1 files changed, 39 insertions, 24 deletions
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 34a3dc1513b..beeccf6373e 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -5,7 +5,7 @@
5;; Author: Karl Fogel <kfogel@cyclic.com> 5;; Author: Karl Fogel <kfogel@cyclic.com>
6;; Maintainer: Karl Fogel <kfogel@cyclic.com> 6;; Maintainer: Karl Fogel <kfogel@cyclic.com>
7;; Created: July, 1993 7;; Created: July, 1993
8;; Version: 2.6.5 8;; Version: 2.6.6
9;; Keywords: bookmarks, placeholders, annotations 9;; Keywords: bookmarks, placeholders, annotations
10 10
11;;; Summary: 11;;; Summary:
@@ -68,7 +68,7 @@
68;; LCD Archive Entry: 68;; LCD Archive Entry:
69;; bookmark|Karl Fogel|kfogel@cyclic.com| 69;; bookmark|Karl Fogel|kfogel@cyclic.com|
70;; Setting bookmarks in files or directories, jumping to them later.| 70;; Setting bookmarks in files or directories, jumping to them later.|
71;; 06-March-1995|Version: 2.6.5|~/misc/bookmark.el.Z| 71;; 06-March-1995|Version: 2.6.6|~/misc/bookmark.el.Z|
72 72
73;; Enough with the credits already, get on to the good stuff: 73;; Enough with the credits already, get on to the good stuff:
74 74
@@ -446,18 +446,22 @@ Takes ANNOTATION as an argument."
446 (front-context-string 446 (front-context-string
447 . (, (if (>= (- (point-max) (point)) bookmark-search-size) 447 . (, (if (>= (- (point-max) (point)) bookmark-search-size)
448 ;; strip text props via `format': 448 ;; strip text props via `format':
449 (format "%s" 449 (let ((string
450 (buffer-substring 450 (buffer-substring
451 (point) 451 (point)
452 (+ (point) bookmark-search-size))) 452 (+ (point) bookmark-search-size))))
453 (set-text-properties 0 (length string) nil string)
454 string)
453 nil))) 455 nil)))
454 (rear-context-string 456 (rear-context-string
455 . (, (if (>= (- (point) (point-min)) bookmark-search-size) 457 . (, (if (>= (- (point) (point-min)) bookmark-search-size)
456 ;; strip text props via `format': 458 ;; strip text props via `format':
457 (format "%s" 459 (let ((string
458 (buffer-substring 460 (buffer-substring
459 (point) 461 (point)
460 (- (point) bookmark-search-size))) 462 (- (point) bookmark-search-size))))
463 (set-text-properties 0 (length string) nil string)
464 string)
461 nil))) 465 nil)))
462 (position . (, (point))) 466 (position . (, (point)))
463 (annotation . (, annotation))))) 467 (annotation . (, annotation)))))
@@ -668,7 +672,7 @@ the list of bookmarks.\)"
668 (progn (define-key now-map "\C-w" 672 (progn (define-key now-map "\C-w"
669 'bookmark-yank-word) 673 'bookmark-yank-word)
670 (define-key now-map "\C-v" 674 (define-key now-map "\C-v"
671 'bookmark-insert-current-file-name) 675 'bookmark-insert-buffer-name)
672 (define-key now-map "\C-u" 676 (define-key now-map "\C-u"
673 'bookmark-insert-current-bookmark)) 677 'bookmark-insert-current-bookmark))
674 now-map))) 678 now-map)))
@@ -841,20 +845,44 @@ as the new annotation for a bookmark."
841 (save-excursion 845 (save-excursion
842 (set-buffer bookmark-current-buffer) 846 (set-buffer bookmark-current-buffer)
843 bookmark-current-bookmark))) 847 bookmark-current-bookmark)))
844 (if str (insert str) (bookmark-insert-current-file-name)))) 848 (if str (insert str) (bookmark-insert-buffer-name))))
845 849
846 850
847(defun bookmark-insert-current-file-name () 851(defun bookmark-insert-buffer-name ()
848 ;; insert the name (sans path) of the current file into the bookmark 852 ;; insert the name (sans path) of the current file into the bookmark
849 ;; name that is being set. 853 ;; name that is being set.
850 (interactive) 854 (interactive)
851 (let ((str 855 (let ((str
852 (save-excursion 856 (save-excursion
853 (set-buffer bookmark-current-buffer) 857 (set-buffer bookmark-current-buffer)
854 (file-name-nondirectory (bookmark-buffer-file-name))))) 858 (bookmark-buffer-name))))
855 (insert str))) 859 (insert str)))
856 860
857 861
862(defun bookmark-buffer-name ()
863 "Return the name of the current buffer's file, non-directory.
864In Info, return the current node."
865 (cond
866 ;; Are we in Info?
867 ((string-equal mode-name "Info") Info-current-node)
868 ;; Or are we a file?
869 (buffer-file-name (file-name-nondirectory buffer-file-name))
870 ;; Or are we a directory?
871 ((and (boundp 'dired-directory) dired-directory)
872 (let* ((dirname (if (stringp dired-directory)
873 dired-directory
874 (car dired-directory)))
875 (idx (1- (length dirname))))
876 ;; Strip the trailing slash.
877 (if (= ?/ (aref dirname idx))
878 (file-name-nondirectory (substring dirname 0 idx))
879 ;; Else return the current-buffer
880 (buffer-name (current-buffer)))))
881 ;; If all else fails, use the buffer's name.
882 (t
883 (buffer-name (current-buffer)))))
884
885
858(defun bookmark-yank-word () 886(defun bookmark-yank-word ()
859 (interactive) 887 (interactive)
860 ;; get the next word from the buffer and append it to the name of 888 ;; get the next word from the buffer and append it to the name of
@@ -883,19 +911,6 @@ For example, if this is a Info buffer, return the Info file's name."
883 (car dired-directory)))))) 911 (car dired-directory))))))
884 912
885 913
886(defun bookmark-buffer-name ()
887 "Return the name of the current buffer in a way useful for bookmarks.
888For example, if this is a Info buffer, return the Info node's name."
889 (if (string-equal mode-name "Info")
890 Info-current-node
891 (or
892 buffer-file-name
893 (if (and (boundp 'dired-directory) dired-directory)
894 (if (stringp dired-directory)
895 dired-directory
896 (car dired-directory))))))
897
898
899(defun bookmark-maybe-load-default-file () 914(defun bookmark-maybe-load-default-file ()
900 (and (not bookmarks-already-loaded) 915 (and (not bookmarks-already-loaded)
901 (null bookmark-alist) 916 (null bookmark-alist)
@@ -1081,7 +1096,7 @@ just want to make minor changes to the old name."
1081 (interactive) 1096 (interactive)
1082 (insert old))) 1097 (insert old)))
1083 (define-key now-map "\C-v" 1098 (define-key now-map "\C-v"
1084 'bookmark-insert-current-file-name)) 1099 'bookmark-insert-buffer-name))
1085 now-map))))) 1100 now-map)))))
1086 (progn 1101 (progn
1087 (bookmark-set-name old newname) 1102 (bookmark-set-name old newname)