Implement link folding
* lisp/ol.el (org-link--link-folding-spec): (org-link--description-folding-spec): New variables controlling link folding settings. (org-link--reveal-maybe): Handle revealing folded links. (org-link-descriptive-ensure): Implement `org-link-descriptive' support with org-fold. (org-toggle-link-display--overlays): (org-toggle-link-display--text-properties): (org-toggle-link-display): Provide text-properties and overlays versions. * lisp/org-agenda.el (org-agenda-mode): Use org-fold to fold links in agenda. * lisp/org.el (org-do-emphasis-faces): Use org-fold.
This commit is contained in:
parent
fa7530c7b4
commit
67275f4664
42
lisp/ol.el
42
lisp/ol.el
|
@ -605,6 +605,22 @@ exact and fuzzy text search.")
|
|||
(defvar org-link--search-failed nil
|
||||
"Non-nil when last link search failed.")
|
||||
|
||||
|
||||
(defvar-local org-link--link-folding-spec '(org-link
|
||||
(:global t)
|
||||
(:ellipsis . nil)
|
||||
(:isearch-open . t)
|
||||
(:fragile . org-link--reveal-maybe))
|
||||
"Folding spec used to hide invisible parts of links.")
|
||||
|
||||
(defvar-local org-link--description-folding-spec '(org-link-description
|
||||
(:global t)
|
||||
(:ellipsis . nil)
|
||||
(:visible . t)
|
||||
(:isearch-open . nil)
|
||||
(:fragile . org-link--reveal-maybe))
|
||||
"Folding spec used to reveal link description.")
|
||||
|
||||
|
||||
;;; Internal Functions
|
||||
|
||||
|
@ -762,6 +778,13 @@ syntax around the string."
|
|||
(t nil))))
|
||||
string))
|
||||
|
||||
(defun org-link--reveal-maybe (region _)
|
||||
"Reveal folded link in REGION when needed.
|
||||
This function is intended to be used as :fragile property of a folding
|
||||
spec."
|
||||
(org-with-point-at (car region)
|
||||
(not (org-in-regexp org-link-any-re))))
|
||||
|
||||
|
||||
;;; Public API
|
||||
|
||||
|
@ -1444,14 +1467,31 @@ If the link is in hidden text, expose it."
|
|||
(interactive)
|
||||
(org-next-link t))
|
||||
|
||||
(defun org-link-descriptive-ensure ()
|
||||
"Toggle the literal or descriptive display of links in current buffer if needed."
|
||||
(if org-link-descriptive
|
||||
(org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible nil)
|
||||
(org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-toggle-link-display ()
|
||||
(defun org-toggle-link-display--overlays ()
|
||||
"Toggle the literal or descriptive display of links."
|
||||
(interactive)
|
||||
(if org-link-descriptive (remove-from-invisibility-spec '(org-link))
|
||||
(add-to-invisibility-spec '(org-link)))
|
||||
(org-restart-font-lock)
|
||||
(setq org-link-descriptive (not org-link-descriptive)))
|
||||
(defun org-toggle-link-display--text-properties ()
|
||||
"Toggle the literal or descriptive display of links in current buffer."
|
||||
(interactive)
|
||||
(setq org-link-descriptive (not org-link-descriptive))
|
||||
(org-link-descriptive-ensure))
|
||||
(defsubst org-toggle-link-display ()
|
||||
"Toggle the literal or descriptive display of links."
|
||||
(interactive)
|
||||
(if (eq org-fold-core-style 'text-properties)
|
||||
(org-toggle-link-display--text-properties)
|
||||
(org-toggle-link-display--overlays)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-store-link (arg &optional interactive?)
|
||||
|
|
|
@ -2325,7 +2325,8 @@ The following commands are available:
|
|||
org-agenda-show-log org-agenda-start-with-log-mode
|
||||
org-agenda-clockreport-mode org-agenda-start-with-clockreport-mode))
|
||||
(add-to-invisibility-spec '(org-filtered))
|
||||
(add-to-invisibility-spec '(org-link))
|
||||
(org-fold-core-initialize `(,org-link--description-folding-spec
|
||||
,org-link--link-folding-spec))
|
||||
(easy-menu-change
|
||||
'("Agenda") "Agenda Files"
|
||||
(append
|
||||
|
|
11
lisp/org.el
11
lisp/org.el
|
@ -4563,9 +4563,16 @@ The following commands are available:
|
|||
(setq-local org-mode-loading t)
|
||||
(org-load-modules-maybe)
|
||||
(org-install-agenda-files-menu)
|
||||
(when org-link-descriptive (add-to-invisibility-spec '(org-link)))
|
||||
(when (and org-link-descriptive
|
||||
(eq org-fold-core-style 'overlays))
|
||||
(add-to-invisibility-spec '(org-link)))
|
||||
(org-fold-initialize (or (and (stringp org-ellipsis) (not (equal "" org-ellipsis)) org-ellipsis)
|
||||
"..."))
|
||||
(make-local-variable 'org-link-descriptive)
|
||||
(add-to-invisibility-spec '(org-hide-block . t))
|
||||
(when (eq org-fold-core-style 'overlays) (add-to-invisibility-spec '(org-hide-block . t)))
|
||||
(if org-link-descriptive
|
||||
(org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible nil)
|
||||
(org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) :visible t))
|
||||
(setq-local outline-regexp org-outline-regexp)
|
||||
(setq-local outline-level 'org-outline-level)
|
||||
(setq bidi-paragraph-direction 'left-to-right)
|
||||
|
|
Loading…
Reference in New Issue