[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [RFC] Change visibility for bracket links
From: |
Nicolas Goaziou |
Subject: |
Re: [O] [RFC] Change visibility for bracket links |
Date: |
Wed, 05 Oct 2016 23:13:49 +0200 |
Marco Wahl <address@hidden> 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,
>From 518363a2b794fc21d28987dd59a65c0efa1d9ce4 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <address@hidden>
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 "*<point>"
- (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 "*<point>"
- (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
- [O] [RFC] Change visibility for bracket links, Nicolas Goaziou, 2016/10/05
- Re: [O] [RFC] Change visibility for bracket links, Rainer M Krug, 2016/10/05
- Re: [O] [RFC] Change visibility for bracket links, Marco Wahl, 2016/10/05
- Re: [O] [RFC] Change visibility for bracket links,
Nicolas Goaziou <=
- Re: [O] [RFC] Change visibility for bracket links, Detlef Steuer, 2016/10/05
- Message not available
- Re: [O] [RFC] Change visibility for bracket links, David A. Gershman, 2016/10/05
- Re: [O] [RFC] Change visibility for bracket links, Nicolas Goaziou, 2016/10/05
- Re: [O] [RFC] Change visibility for bracket links, David A. Gershman, 2016/10/05
- Re: [O] [RFC] Change visibility for bracket links, Clément Pit--Claudel, 2016/10/05
- Re: [O] [RFC] Change visibility for bracket links, Nicolas Goaziou, 2016/10/07
- Re: [O] [RFC] Change visibility for bracket links, Rasmus, 2016/10/12
- Message not available
- Re: [O] [RFC] Change visibility for bracket links, Eric S Fraga, 2016/10/06
- Re: [O] [RFC] Change visibility for bracket links, William Denton, 2016/10/06
Re: [O] [RFC] Change visibility for bracket links, Adam Porter, 2016/10/07