Function: bookmark-buffer-name
bookmark-buffer-name is a byte-compiled function defined in
bookmark.el.gz.
Signature
(bookmark-buffer-name)
Documentation
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.
Source Code
;; Defined in /usr/src/emacs/lisp/bookmark.el.gz
(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."
(cond
;; Or are we a file?
(buffer-file-name (file-name-nondirectory buffer-file-name))
;; Or are we a directory?
((and (boundp 'dired-directory) dired-directory)
(let* ((dirname (if (stringp dired-directory)
dired-directory
(car dired-directory)))
(idx (1- (length dirname))))
;; Strip the trailing slash.
(if (= ?/ (aref dirname idx))
(file-name-nondirectory (substring dirname 0 idx))
;; Else return the current-buffer
(buffer-name (current-buffer)))))
;; If all else fails, use the buffer's name.
(t
(buffer-name (current-buffer)))))