From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [RFC] Change visibility for bracket links Date: Wed, 05 Oct 2016 23:13:49 +0200 Message-ID: <87h98qmrci.fsf@nicolasgoaziou.fr> References: <87bmyyold3.fsf@nicolasgoaziou.fr> <8460p6u4jg.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brtVg-0004Ez-99 for emacs-orgmode@gnu.org; Wed, 05 Oct 2016 17:13:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brtVd-0001xu-FO for emacs-orgmode@gnu.org; Wed, 05 Oct 2016 17:13:51 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:56753) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brtVd-0001xa-5l for emacs-orgmode@gnu.org; Wed, 05 Oct 2016 17:13:49 -0400 In-Reply-To: <8460p6u4jg.fsf@gmail.com> (Marco Wahl's message of "Wed, 05 Oct 2016 18:46:59 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Marco Wahl Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Marco Wahl writes: > I think there is an issue with the coloring when writing text > immediately to the right of a file link. E.g. > > [[file:shot.png]]text You are right. I didn't check the patch thoroughly. Here is an update, which should be more robust. Regards, --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Change-bracket-links-visibility.patch >From 518363a2b794fc21d28987dd59a65c0efa1d9ce4 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. Small refactoring. (org-beginning-of-line): (org-end-of-line): Remove workaround bug #14346, since the original report cannot be reproduced. * testing/lisp/test-org.el (test-org/beginning-of-line): Fix test. --- lisp/org.el | 66 +++++++++++++++++++++--------------------------- testing/lisp/test-org.el | 4 +-- 2 files changed, 31 insertions(+), 39 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 6d5201b..fcc60d3 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -6163,7 +6163,6 @@ by a #." (match-string-no-properties 2 hl)))) (link-start (match-beginning 0)) (link-end (match-end 0)) - (bracketp t) (help-echo (org-link-get-parameter type :help-echo)) (help (cond ((stringp help-echo) @@ -6199,44 +6198,43 @@ 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))) - ;; We need to remove the invisible property here. Table narrowing - ;; may have made some of this invisible. + '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) - (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) - (org-rear-nonsticky-at (match-end 0))) + (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) + ;; Make sure text after the visible closing bracket gets + ;; past the whole link. + (add-text-properties (match-end 2) (match-end 0) + `(rear-nonsticky ,ip)) + (add-text-properties (match-end 2) (match-end 0) + `(front-sticky ,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) + ;; Make sure text after the visible closing bracket gets past + ;; the whole link. + (add-text-properties (match-end 1) (match-end 0) `(rear-nonsticky ,ip)) + (add-text-properties (match-end 1) (match-end 0) `(front-sticky ,ip))) (when activate-func - (funcall activate-func link-start link-end path bracketp)) + (funcall activate-func link-start link-end path t)) t))) (defun org-activate-dates (limit) @@ -23762,10 +23760,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 +23797,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) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 56ccfd6..29d933b 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -2491,10 +2491,10 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/" ;; asterisk. (should (org-test-with-temp-text "*" - (let ((org-special-ctrl-a/e t)) (org-beginning-of-line)))) + (let ((org-special-ctrl-a/e t)) (org-beginning-of-line) t))) (should (org-test-with-temp-text "*" - (let ((org-special-ctrl-a/e nil)) (org-beginning-of-line))))) + (let ((org-special-ctrl-a/e nil)) (org-beginning-of-line) t)))) (ert-deftest test-org/end-of-line () "Test `org-end-of-line' specifications." -- 2.9.3 --=-=-=--