在emacs的模式行中显示书签名称

时间:2013-07-19 16:50:56

标签: emacs bookmarks

如何在emacs的模式行中显示书签的名称(来自“书签”或“书签+”),而不是文件名?

1 个答案:

答案 0 :(得分:1)

一个稍微奇怪的请求,但是你去(适用于文件和直接缓冲区):

(defun show-bookmarks-mode-line ()
  (interactive)
  (let (bname text)
    (and
     (setq bname (if (eq major-mode 'dired-mode)
                     default-directory
                   (buffer-file-name)))
     (setq bname (expand-file-name bname))
     (setq text
           (delq nil
                 (mapcar
                  (lambda (x)
                    (and (equal bname
                                (expand-file-name
                                 (bookmark-get-filename x)))
                         (substring-no-properties (car x))))
                  bookmark-alist)))
     (setq text
           (mapconcat
            #'identity
            text
            ", "))
     (let ((mode-line-buffer-identification
            (propertize text 'face 'mode-line-buffer-id)))
       (force-mode-line-update)
       (sit-for 5))
     (force-mode-line-update))))

你能详细说明你为什么需要吗?