From 768d77be335e1e5e0a4afa9bf7dbd89f9c5ab65e Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 5 Oct 2016 17:22:15 +0200 Subject: [PATCH] Change bracket links visibility * lisp/org.el (org-activate-bracket-links): Leave a pair of brackets around bracket links so as to facilitate editing them. --- lisp/org.el | 49 ++++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 6d5201b..25f48e3 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6199,41 +6199,34 @@ by a #." (t `(:uri ,(format "%s:%s" type path))))) (activate-func (org-link-get-parameter type :activate-func)) - ;; invisible part - (ip (list 'invisible (or - (org-link-get-parameter type :display) - 'org-link) - 'face face - 'keymap keymap - 'mouse-face mouse-face - 'font-lock-multiline t - 'help-echo help - 'htmlize-link htmlize-link)) - ;; visible part + ;; Visible part. (vp (list 'keymap keymap 'face face 'mouse-face mouse-face 'font-lock-multiline t 'help-echo help - 'htmlize-link htmlize-link))) + 'htmlize-link htmlize-link)) + ;; Invisible part. + (ip (append (list 'invisible + (or (org-link-get-parameter type :display) + 'org-link)) + vp))) ;; We need to remove the invisible property here. Table narrowing ;; may have made some of this invisible. (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0)) (remove-text-properties (match-beginning 0) (match-end 0) '(invisible nil)) - (if (match-end 3) + (if (match-end 2) (progn - (add-text-properties (match-beginning 0) (match-beginning 3) ip) - (org-rear-nonsticky-at (match-beginning 3)) - (add-text-properties (match-beginning 3) (match-end 3) vp) - (org-rear-nonsticky-at (match-end 3)) - (add-text-properties (match-end 3) (match-end 0) ip) + (add-text-properties (match-beginning 0) (match-beginning 2) ip) + (add-text-properties (match-beginning 2) (match-end 2) vp) + (add-text-properties (match-end 2) (match-end 0) ip) + ;; The following is needed so as characters inserted after + ;; the closing bracket do not enter the link. (org-rear-nonsticky-at (match-end 0))) - (add-text-properties (match-beginning 0) (match-beginning 1) ip) - (org-rear-nonsticky-at (match-beginning 1)) - (add-text-properties (match-beginning 1) (match-end 1) vp) - (org-rear-nonsticky-at (match-end 1)) - (add-text-properties (match-end 1) (match-end 0) ip) + (add-text-properties (match-beginning 0) (1+ (match-beginning 0)) ip) + (add-text-properties (1+ (match-beginning 0)) (1+ (match-end 1)) vp) + (add-text-properties (1+ (match-end 1)) (match-end 0) ip) (org-rear-nonsticky-at (match-end 0))) (when activate-func (funcall activate-func link-start link-end path bracketp)) @@ -23762,10 +23755,7 @@ beyond the end of the headline." ;; point was already at beginning of line and command is ;; repeated. (when (and (= (point) pos) (eq last-command this-command)) - (goto-char after-bullet)))))))) - (setq disable-point-adjustment - (or (not (invisible-p (point))) - (not (invisible-p (max (point-min) (1- (point)))))))) + (goto-char after-bullet))))))))) (defun org-end-of-line (&optional arg) "Go to the end of the line. @@ -23802,10 +23792,7 @@ the cursor is already beyond the end of the headline." ;; If element is hidden, `move-end-of-line' would put point ;; after it. Use `end-of-line' to stay on current line. (call-interactively 'end-of-line)) - (t (call-interactively move-fun)))))) - (setq disable-point-adjustment - (or (not (invisible-p (point))) - (not (invisible-p (max (point-min) (1- (point)))))))) + (t (call-interactively move-fun))))))) (define-key org-mode-map "\C-a" 'org-beginning-of-line) (define-key org-mode-map "\C-e" 'org-end-of-line) -- 2.9.3