org.el (org-display-outline-path): New argument `as-string'

* org.el (org-display-outline-path): New argument `as-string'.

This useful if you want to display the outline path in the
minibuffer like this:

(add-hook 'org-mode-hook
          (lambda() (add-to-list 'mode-line-format
                                 '(:eval (org-display-outline-path nil t t)) t)))
This commit is contained in:
Bastien Guerry 2012-09-25 03:43:41 +02:00
parent bf072bd647
commit 044dbf680e
1 changed files with 9 additions and 7 deletions

View File

@ -10870,22 +10870,24 @@ such as the file name."
h) h)
path "/"))))) path "/")))))
(defun org-display-outline-path (&optional file current) (defun org-display-outline-path (&optional file current as-string)
"Display the current outline path in the echo area." "Display the current outline path in the echo area."
(interactive "P") (interactive "P")
(let* ((bfn (buffer-file-name (buffer-base-buffer))) (let* ((bfn (buffer-file-name (buffer-base-buffer)))
(case-fold-search nil) (case-fold-search nil)
(path (and (derived-mode-p 'org-mode) (org-get-outline-path)))) (path (and (derived-mode-p 'org-mode) (org-get-outline-path)))
res)
(if current (setq path (append path (if current (setq path (append path
(save-excursion (save-excursion
(org-back-to-heading t) (org-back-to-heading t)
(if (looking-at org-complex-heading-regexp) (if (looking-at org-complex-heading-regexp)
(list (match-string 4))))))) (list (match-string 4)))))))
(message "%s" (setq res
(org-format-outline-path (org-format-outline-path
path path
(1- (frame-width)) (1- (frame-width))
(and file bfn (concat (file-name-nondirectory bfn) "/")))))) (and file bfn (concat (file-name-nondirectory bfn) "/"))))
(if as-string (org-no-properties res) (message "%s" res))))
(defvar org-refile-history nil (defvar org-refile-history nil
"History for refiling operations.") "History for refiling operations.")