* Link "bracket-types" @ 2018-05-10 6:08 Michael Brand 2018-05-10 8:14 ` Nicolas Goaziou 0 siblings, 1 reply; 21+ messages in thread From: Michael Brand @ 2018-05-10 6:08 UTC (permalink / raw To: Org Mode Hi all For the four different Org link "bracket-types" shown below I would like to have four different faces to be able to distinguish them at first sight. What is the recommended way to do this? The four Org link bracket-types by example: Buffer raw content (or visible-mode): : 1) [[https://en.wikipedia.org/wiki/Filter#References][https://en.wikipedia.org/wiki/Filter]] : 2) https://en.wikipedia.org/wiki/Filter : 3) [[https://en.wikipedia.org/wiki/Filter]] : 4) [[https://en.wikipedia.org/wiki/Filter_(higher-order_function)]] (To try them out copy the above into an Org buffer and remove the colons.) Currently rendered all with the same face as: : 1) https://en.wikipedia.org/wiki/Filter : 2) https://en.wikipedia.org/wiki/Filter : 3) https://en.wikipedia.org/wiki/Filter : 4) https://en.wikipedia.org/wiki/Filter_(higher-order_function) As you know and can see above 1) to 3) can not be distinguished when rendered with the default of org-descriptive-links t. The brackets for 3) are optional as 2) opens the same URL. The brackets for 4) are mandatory because without them "_(higher-order_function)" is not fontified and not recognized by org-open-at-point as part of the Org link any more. I think 4) can be distinguished from 3) by comparing the bracket content with the part fontified and/or recognized as Org link when the bracket content without the brackets is matched/parsed again stand-alone. org-descriptive-links permanently nil does not seem to be an alternative as it disturbs text flow and org-fill-paragraph. org-toggle-link-display does not seem to be an alternative as it would have to be toggled forth and back on every new window scroll view. Michael ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 6:08 Link "bracket-types" Michael Brand @ 2018-05-10 8:14 ` Nicolas Goaziou 2018-05-10 8:32 ` Eric S Fraga 2018-05-10 9:41 ` Michael Brand 0 siblings, 2 replies; 21+ messages in thread From: Nicolas Goaziou @ 2018-05-10 8:14 UTC (permalink / raw To: Michael Brand; +Cc: Org Mode Hello, Michael Brand <michael.ch.brand@gmail.com> writes: > > For the four different Org link "bracket-types" shown below I would > like to have four different faces to be able to distinguish them at > first sight. What is the recommended way to do this? This is not possible. I'm not even sure this is desirable. Note that 2) is not a "bracket type". > The four Org link bracket-types by example: > > Buffer raw content (or visible-mode): > : 1) [[https://en.wikipedia.org/wiki/Filter#References][https://en.wikipedia.org/wiki/Filter]] > : 2) https://en.wikipedia.org/wiki/Filter > : 3) [[https://en.wikipedia.org/wiki/Filter]] > : 4) [[https://en.wikipedia.org/wiki/Filter_(higher-order_function)]] > > (To try them out copy the above into an Org buffer and remove the colons.) > > Currently rendered all with the same face as: > : 1) https://en.wikipedia.org/wiki/Filter > : 2) https://en.wikipedia.org/wiki/Filter > : 3) https://en.wikipedia.org/wiki/Filter > : 4) https://en.wikipedia.org/wiki/Filter_(higher-order_function) > > As you know and can see above 1) to 3) can not be distinguished when > rendered with the default of org-descriptive-links t. Just move the mouse over them. A tooltip or the minibuffer will display what the link is really. > The brackets for 3) are optional as 2) opens the same URL. They are strictly equivalent, indeed. > The brackets for 4) are mandatory because without them > "_(higher-order_function)" is not fontified and not recognized by > org-open-at-point as part of the Org link any more. True. This limitation is a feature. You cannot have parenthesis in plain links even though they are technically allowed in URL. However, you could also use angle brackets. <https://en.wikipedia.org/wiki/Filter_(higher-order_function)> The advantage on angle brackets is that they make it clear there is no description attached to the link, i.e., the brackets are visible when fontified). You can also use angle brackets for a more prominent visual clue. I'm not sure to understand the problem you want to solve. What is important is if the displayed part of a link is a description or the URL itself, i.e., case 1. This is solved by hovering the mouse above the link. The other cases are equivalent, barring the limitation from case 2. Regards, -- Nicolas Goaziou ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 8:14 ` Nicolas Goaziou @ 2018-05-10 8:32 ` Eric S Fraga 2018-05-11 12:34 ` Nicolas Goaziou 2018-05-10 9:41 ` Michael Brand 1 sibling, 1 reply; 21+ messages in thread From: Eric S Fraga @ 2018-05-10 8:32 UTC (permalink / raw To: Nicolas Goaziou; +Cc: Michael Brand, Org Mode [-- Attachment #1: Type: text/plain, Size: 657 bytes --] On Thursday, 10 May 2018 at 10:14, Nicolas Goaziou wrote: > Michael Brand <michael.ch.brand@gmail.com> writes: [...] >> As you know and can see above 1) to 3) can not be distinguished when >> rendered with the default of org-descriptive-links t. > > Just move the mouse over them. A tooltip or the minibuffer will display > what the link is really. Feature request: would it be possible to have the link echoed in the minibuffer when point enters or is on a link? I don't use the mouse at all and always end up having to C-c l to see what the link is. thanks, eric -- Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-591-gee336b [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 194 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 8:32 ` Eric S Fraga @ 2018-05-11 12:34 ` Nicolas Goaziou 2018-05-11 13:20 ` Eric S Fraga 0 siblings, 1 reply; 21+ messages in thread From: Nicolas Goaziou @ 2018-05-11 12:34 UTC (permalink / raw To: Michael Brand; +Cc: Org Mode Hello, Eric S Fraga <esflists@gmail.com> writes: > Feature request: would it be possible to have the link echoed in the > minibuffer when point enters or is on a link? I don't use the mouse at > all and always end up having to C-c l to see what the link is. You can use :activate-func link parameter (see `org-link-parameters') to set `cursor-sensor-functions'. Regards, -- Nicolas Goaziou ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-11 12:34 ` Nicolas Goaziou @ 2018-05-11 13:20 ` Eric S Fraga 0 siblings, 0 replies; 21+ messages in thread From: Eric S Fraga @ 2018-05-11 13:20 UTC (permalink / raw To: Nicolas Goaziou; +Cc: Michael Brand, Org Mode [-- Attachment #1: Type: text/plain, Size: 852 bytes --] On Friday, 11 May 2018 at 14:34, Nicolas Goaziou wrote: > Hello, > > Eric S Fraga <esflists@gmail.com> writes: > >> Feature request: would it be possible to have the link echoed in the >> minibuffer when point enters or is on a link? I don't use the mouse at >> all and always end up having to C-c l to see what the link is. > > You can use :activate-func link parameter (see `org-link-parameters') to > set `cursor-sensor-functions'. Thank you. But I would need to redefine all link types, I guess, to include this setting (and would need to write the function as well which is arguably beyond my capabilities ;-)). I was suggesting this as something that should be the default behaviour but it's nice to know that it's possible to achieve. For a rainy day! -- Eric S Fraga via Emacs 27.0.50, Org release_9.1.11-620-ga548e4 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 194 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 8:14 ` Nicolas Goaziou 2018-05-10 8:32 ` Eric S Fraga @ 2018-05-10 9:41 ` Michael Brand 2018-05-10 12:44 ` Nicolas Goaziou 1 sibling, 1 reply; 21+ messages in thread From: Michael Brand @ 2018-05-10 9:41 UTC (permalink / raw To: Nicolas Goaziou; +Cc: Org Mode Hi Nicolas Thank you for looking into this. On Thu, May 10, 2018 at 10:14 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote: > Just move the mouse over them. A tooltip or the minibuffer will display > what the link is really. During my use case I don't care what URL the link opens. I want to know if there are brackets and even better when I know whether they are case 1 or 3/4. > True. This limitation is a feature. You cannot have parenthesis in plain > links even though they are technically allowed in URL. > > However, you could also use angle brackets. > > <https://en.wikipedia.org/wiki/Filter_(higher-order_function)> > > The advantage on angle brackets is that they make it clear there is no > description attached to the link, i.e., the brackets are visible when > fontified). You can also use angle brackets for a more prominent visual > clue. Good to know, I didn't (or forgot?). > I'm not sure to understand the problem you want to solve. What is > important is if the displayed part of a link is a description or the URL > itself, i.e., case 1. This is solved by hovering the mouse above the > link. The other cases are equivalent, barring the limitation from case > 2. My use case is different, see above, and I don't like to move point or mouse for my use case. I would like to have a visual indication like with org-descriptive-links nil which leads to this thought: Probably better than more faces would be to render case 1 like with org-descriptive-links t and case 3/4 like with org-descriptive-links nil. What would be the recommended way to do this? Could that become a new value beside the current t and nil for org-descriptive-links? Michael ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 9:41 ` Michael Brand @ 2018-05-10 12:44 ` Nicolas Goaziou 2018-05-10 13:23 ` Michael Brand 0 siblings, 1 reply; 21+ messages in thread From: Nicolas Goaziou @ 2018-05-10 12:44 UTC (permalink / raw To: Michael Brand; +Cc: Org Mode Michael Brand <michael.ch.brand@gmail.com> writes: > My use case is different, see above, and I don't like to move point or > mouse for my use case. I still don't understand what your use case is about. Why do you care about the presence of square brackets? It is difficult to think about the pertinence of a solution if the problem is not well defined. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 12:44 ` Nicolas Goaziou @ 2018-05-10 13:23 ` Michael Brand 2018-05-10 13:33 ` Nicolas Goaziou 0 siblings, 1 reply; 21+ messages in thread From: Michael Brand @ 2018-05-10 13:23 UTC (permalink / raw To: Nicolas Goaziou; +Cc: Org Mode Hi Nicolas On Thu, May 10, 2018 at 2:44 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote: > I still don't understand what your use case is about. Why do you care > about the presence of square brackets? Because I care about the raw file content that I see when using non-Org tools like mainly git but also diff, grep, less, vi and whatever. > It is difficult to think about the pertinence of a solution if the > problem is not well defined. I could use org-descriptive-links nil to make the brackets visible. But I would prefer a compromise like I mentioned in my last post: Case 1 like with org-descriptive-links t and case 3/4 like with org-descriptive-links nil. Michael ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 13:23 ` Michael Brand @ 2018-05-10 13:33 ` Nicolas Goaziou 2018-05-10 14:29 ` Michael Brand 0 siblings, 1 reply; 21+ messages in thread From: Nicolas Goaziou @ 2018-05-10 13:33 UTC (permalink / raw To: Michael Brand; +Cc: Org Mode Michael Brand <michael.ch.brand@gmail.com> writes: > Because I care about the raw file content that I see when using > non-Org tools like mainly git but also diff, grep, less, vi and > whatever. Sorry for being dense, but I still don't get it. When using non-Org tools, the solution doesn't belong to Org, does it? I mean, we are talking about fontification in Emacs Org mode. Tweaking it will not change the output of these other tools. This is probably obvious to you, but again, this is a genuine question: how would you use /in Org/ the information about the brackets surrounding the link? A concrete example would probably help. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 13:33 ` Nicolas Goaziou @ 2018-05-10 14:29 ` Michael Brand 2018-05-10 16:27 ` Nicolas Goaziou 0 siblings, 1 reply; 21+ messages in thread From: Michael Brand @ 2018-05-10 14:29 UTC (permalink / raw To: Nicolas Goaziou; +Cc: Org Mode Hi Nicolas On Thu, May 10, 2018 at 3:33 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote: > Sorry for being dense, but I still don't get it. I can not claim to have been clear enough, hope to make it clearer below. > When using non-Org tools, the solution doesn't belong to Org, does it? > I mean, we are talking about fontification in Emacs Org mode. Tweaking > it will not change the output of these other tools. Agreed. > This is probably obvious to you, but again, this is a genuine question: > how would you use /in Org/ the information about the brackets > surrounding the link? A concrete example would probably help. Only when I can see the brackets of case 3 in Org rendered as : [[https://en.wikipedia.org/wiki/Filter]] I know that I can change it to : https://en.wikipedia.org/wiki/Filter for a cleaner view in non-Org tools. For case 1 I still prefer to see only the link description because I prefer to hide a too disturbing URL part most of the times. My example for case 1 is only artificial and my actual descriptions will be such that it can not be confused with case 2. I hope the previously described idea of a third value for org-descriptive-links or something similar makes some sense. Michael ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 14:29 ` Michael Brand @ 2018-05-10 16:27 ` Nicolas Goaziou 2018-05-10 19:58 ` Samuel Wales 2018-05-10 19:59 ` Michael Brand 0 siblings, 2 replies; 21+ messages in thread From: Nicolas Goaziou @ 2018-05-10 16:27 UTC (permalink / raw To: Michael Brand; +Cc: Org Mode Michael Brand <michael.ch.brand@gmail.com> writes: > Only when I can see the brackets of case 3 in Org rendered as > : [[https://en.wikipedia.org/wiki/Filter]] > I know that I can change it to > : https://en.wikipedia.org/wiki/Filter > for a cleaner view in non-Org tools. > > For case 1 I still prefer to see only the link description because I > prefer to hide a too disturbing URL part most of the times. My example > for case 1 is only artificial and my actual descriptions will be such > that it can not be confused with case 2. IIUC, you want fontification to make it obvious there are square brackets in links, so that you know when they can be removed, for improved readability outside Org. If I'm correct, why don't you write a function that normalizes links for you, so you don't have to bother, e.g., something that turns [[URL]] into URL unless URL contains parenthesis or spaces? ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 16:27 ` Nicolas Goaziou @ 2018-05-10 19:58 ` Samuel Wales 2018-05-12 23:35 ` Samuel Wales 2018-05-10 19:59 ` Michael Brand 1 sibling, 1 reply; 21+ messages in thread From: Samuel Wales @ 2018-05-10 19:58 UTC (permalink / raw To: Nicolas Goaziou; +Cc: Michael Brand, Org Mode (add-hook 'org-mode-hook 'alpha-eldoc-help-echo-mode) ;; fixme in elisp we want both link eldoc and elisp eldoc (defun hoka-eldoc-help-echo-at-point () "Eldoc thingy for help-echo text properties." (let ((val (get-text-property (point) 'help-echo))) val)) (defun alpha-eldoc-help-echo-mode () "Enable eldoc mode with e.g. org links to display in minibuffer when cursor is over them. Call in the relevant buffer. M-x eldoc-mode to turn off." (interactive) (eval-when-compile (require 'eldoc)) (setq-local eldoc-documentation-function 'hoka-eldoc-help-echo-at-point) (eldoc-mode)) On 5/10/18, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote: > Michael Brand <michael.ch.brand@gmail.com> writes: > >> Only when I can see the brackets of case 3 in Org rendered as >> : [[https://en.wikipedia.org/wiki/Filter]] >> I know that I can change it to >> : https://en.wikipedia.org/wiki/Filter >> for a cleaner view in non-Org tools. >> >> For case 1 I still prefer to see only the link description because I >> prefer to hide a too disturbing URL part most of the times. My example >> for case 1 is only artificial and my actual descriptions will be such >> that it can not be confused with case 2. > > IIUC, you want fontification to make it obvious there are square > brackets in links, so that you know when they can be removed, for > improved readability outside Org. > > If I'm correct, why don't you write a function that normalizes links for > you, so you don't have to bother, e.g., something that turns [[URL]] > into URL unless URL contains parenthesis or spaces? > > -- The Kafka Pandemic: <http://thekafkapandemic.blogspot.com> The disease DOES progress. MANY people have died from it. And ANYBODY can get it at any time. "You’ve really gotta quit this and get moving, because this is murder by neglect." --- <http://www.meaction.net/2017/02/03/pwme-people-with-me-are-being-murdered-by-neglect>. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 19:58 ` Samuel Wales @ 2018-05-12 23:35 ` Samuel Wales 2018-05-13 11:10 ` Eric S Fraga 0 siblings, 1 reply; 21+ messages in thread From: Samuel Wales @ 2018-05-12 23:35 UTC (permalink / raw To: Nicolas Goaziou; +Cc: Michael Brand, Org Mode in case op or anybody else is wondering why i pasted random code, this will show the link location when cursor is over the link. On 5/10/18, Samuel Wales <samologist@gmail.com> wrote: > (add-hook 'org-mode-hook 'alpha-eldoc-help-echo-mode) > ;; fixme in elisp we want both link eldoc and elisp eldoc > (defun hoka-eldoc-help-echo-at-point () > "Eldoc thingy for help-echo text properties." > (let ((val (get-text-property (point) 'help-echo))) > val)) > (defun alpha-eldoc-help-echo-mode () > "Enable eldoc mode with e.g. org links to display in minibuffer > when cursor is over them. Call in the relevant buffer. M-x > eldoc-mode to turn off." > (interactive) > (eval-when-compile (require 'eldoc)) > (setq-local eldoc-documentation-function 'hoka-eldoc-help-echo-at-point) > (eldoc-mode)) ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-12 23:35 ` Samuel Wales @ 2018-05-13 11:10 ` Eric S Fraga 0 siblings, 0 replies; 21+ messages in thread From: Eric S Fraga @ 2018-05-13 11:10 UTC (permalink / raw To: Samuel Wales; +Cc: Org Mode [-- Attachment #1: Type: text/plain, Size: 318 bytes --] On Saturday, 12 May 2018 at 16:35, Samuel Wales wrote: > in case op or anybody else is wondering why i pasted random code, this > will show the link location when cursor is over the link. Excellent! Thank you very much. Works like a charm. -- Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-591-gee336b [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 194 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 16:27 ` Nicolas Goaziou 2018-05-10 19:58 ` Samuel Wales @ 2018-05-10 19:59 ` Michael Brand 2018-05-11 0:22 ` Nicolas Goaziou 1 sibling, 1 reply; 21+ messages in thread From: Michael Brand @ 2018-05-10 19:59 UTC (permalink / raw To: Nicolas Goaziou; +Cc: Org Mode Hi Nicolas On Thu, May 10, 2018 at 6:27 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote: > IIUC, you want fontification to make it obvious there are square > brackets in links, so that you know when they can be removed, for > improved readability outside Org. Yes, and generally just to see what is going on in Org with a little bit more details. In the meantime I tried a changed org-activate-links #+begin_example - (visible-start (or (match-beginning 4) (match-beginning 2))) + (visible-start (or (match-beginning 4) start)) - (visible-end (or (match-end 4) (match-end 2)))) + (visible-end (or (match-end 4) end))) #+end_example to show the brackets of case 3/4 always which I even prefer over my earlier proposal of fontification. And org-toggle-link-display can still be used to toggle case 1. Somehow I don't like to hide the brackets for case 3/4 where nothing else is to be hidden. > If I'm correct, why don't you write a function that normalizes links for > you, so you don't have to bother, e.g., something that turns [[URL]] > into URL unless URL contains parenthesis or spaces? The search criteria is more complex because e. g. : https://en.wikipedia.org/wiki/Filter_(signal_processing) does not need brackets. The changed org-activate-links works better for me than an automatic normalization as I don't need and want to change all : [[URL]] now and prefer something similar to lazy evaluation: Change such links only when I stumble upon for some other reason because after bracket removal or replacement with angle brackets I have to interact anyway with org-fill-paragraph and table realignment etc. because I used org-descriptive-links nil before. Michael ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-10 19:59 ` Michael Brand @ 2018-05-11 0:22 ` Nicolas Goaziou 2018-05-11 13:10 ` Nicolas Goaziou 0 siblings, 1 reply; 21+ messages in thread From: Nicolas Goaziou @ 2018-05-11 0:22 UTC (permalink / raw To: Michael Brand; +Cc: Org Mode Michael Brand <michael.ch.brand@gmail.com> writes: > In the meantime I tried a changed org-activate-links > > #+begin_example > - (visible-start (or (match-beginning 4) (match-beginning 2))) > + (visible-start (or (match-beginning 4) start)) > - (visible-end (or (match-end 4) (match-end 2)))) > + (visible-end (or (match-end 4) end))) > #+end_example If you mean that fontification should show one pair of brackets instead of hiding them all, I suggested it already, users found it added too much cruft. You may want to check ML archives about it. > The search criteria is more complex because e. g. > : https://en.wikipedia.org/wiki/Filter_(signal_processing) > does not need brackets. Of course. The search criteria is : 1. no description, 2. not an internal link, 3. path matches exactly `org-plain-link-re'. I was merely giving you an idea. > The changed org-activate-links works better for me than an automatic > normalization as I don't need and want to change all > : [[URL]] > now and prefer something similar to lazy evaluation: Change such links > only when I stumble upon for some other reason because after bracket > removal or replacement with angle brackets I have to interact anyway > with org-fill-paragraph and table realignment etc. because I used > org-descriptive-links nil before. Your function could take care of filling paragraph and re-aligning table. Anyway, about showing brackets in fontification, see above. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-11 0:22 ` Nicolas Goaziou @ 2018-05-11 13:10 ` Nicolas Goaziou 2018-05-11 13:55 ` Michael Brand 0 siblings, 1 reply; 21+ messages in thread From: Nicolas Goaziou @ 2018-05-11 13:10 UTC (permalink / raw To: Michael Brand; +Cc: Org Mode Completing myself, Nicolas Goaziou <mail@nicolasgoaziou.fr> writes: > If you mean that fontification should show one pair of brackets instead > of hiding them all, I suggested it already, users found it added too > much cruft. > > You may want to check ML archives about it. I searched the ML archives about that. It was a thread named [RFC] Change visibility for bracket links in which you participated. It never ended on anything concrete because the involved participants disagreed on the default value -- or, to put it differently, I disagreed with mostly anyone else -- and some users suggested another way to do it, but never implemented their suggestion fully. Anyway, here is an updated patch from the original thread, as a POC. It adds `partial' to `org-descriptive-links'. It isn't complete, as `org-toggle-link-display' should be altered so as to not modify `org-descriptive-links'. Maybe it's time for an old idea revival. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-11 13:10 ` Nicolas Goaziou @ 2018-05-11 13:55 ` Michael Brand 2018-05-11 14:15 ` Nicolas Goaziou 0 siblings, 1 reply; 21+ messages in thread From: Michael Brand @ 2018-05-11 13:55 UTC (permalink / raw To: Nicolas Goaziou; +Cc: Org Mode On Fri, May 11, 2018 at 3:10 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote: > Completing myself, > > Nicolas Goaziou <mail@nicolasgoaziou.fr> writes: > >> If you mean that fontification should show one pair of brackets instead >> of hiding them all, I suggested it already, users found it added too >> much cruft. >> >> You may want to check ML archives about it. > > I searched the ML archives about that. It was a thread named > > [RFC] Change visibility for bracket links > > in which you participated. > > It never ended on anything concrete because the involved participants > disagreed on the default value -- or, to put it differently, I disagreed > with mostly anyone else -- and some users suggested another way to do > it, but never implemented their suggestion fully. Thanks for the hint, found and read it again: http://lists.gnu.org/archive/html/emacs-orgmode/2016-10/msg00136.html To summarize the thread there, the initial proposal there was that the links #+begin_example 1) [[https://en.wikipedia.org/wiki/Filter][Filter (Wikipedia en)]] 2) https://en.wikipedia.org/wiki/Filter 3) [[https://en.wikipedia.org/wiki/Filter]] 4) [[https://en.wikipedia.org/wiki/Filter_(higher-order_function)]] 5) <https://en.wikipedia.org/wiki/Filter_(higher-order_function)> #+end_example are rendered as #+begin_example 1) [Filter (Wikipedia en)] 2) https://en.wikipedia.org/wiki/Filter 3) [https://en.wikipedia.org/wiki/Filter] 4) [https://en.wikipedia.org/wiki/Filter_(higher-order_function)] 5) <https://en.wikipedia.org/wiki/Filter_(higher-order_function)> #+end_example To summarize the thread here: By changing org-activate-links #+begin_example - (visible-start (or (match-beginning 4) (match-beginning 2))) + (visible-start (or (match-beginning 4) start)) - (visible-end (or (match-end 4) (match-end 2)))) + (visible-end (or (match-end 4) end))) #+end_example the links are rendered as #+begin_example 1) Filter (Wikipedia en) 2) https://en.wikipedia.org/wiki/Filter 3) [[https://en.wikipedia.org/wiki/Filter]] 4) [[https://en.wikipedia.org/wiki/Filter_(higher-order_function)]] 5) <https://en.wikipedia.org/wiki/Filter_(higher-order_function)> #+end_example which for me is the exact right amount of show and hide of _both_ bracket pairs and URL for all cases 1..5 in all my use cases. Inclusive org-toggle-link-display to toggle only case 1. For me this is the better solution than my initial idea of different faces for the different cases. Not at least because aligned tables and filled paragraphs with links like #+begin_example [[abbrev:123]] #+end_example are aligned and filled also in non-Org tools. (For the last reason I use links of case 1 almost never in filled paragraphs, almost only in un-filled paragraphs with Visual Line mode. In filled paragraphs I avoid case 1 by using case 2 (or if necessary 4 or 5) and if helpful prepend a "description" just as Org-semantically normal text, separated from the URL with whitespace.) I will continue to use this change in my local branch. > Anyway, here is an updated patch from the original thread, as a POC. It > adds `partial' to `org-descriptive-links'. It isn't complete, as > `org-toggle-link-display' should be altered so as to not modify > `org-descriptive-links'. Do you mean here attached and updated as of today? > Maybe it's time for an old idea revival. Currently we disagree in that you suggest one bracket where I prefer none for descriptive links and you suggest one bracket where I prefer two for the other cases, see rendering examples and my reasons for raw plain text in non-Org tools above. If there would be an option to show 0 (current behavior), 1 (your suggestion) or 2 brackets (new) everywhere I could use 2 as a compromise. If the option 0, 1 or 2 would be individual for case 1 and for case 3/4 that would of course be perfect at least for me. Michael ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-11 13:55 ` Michael Brand @ 2018-05-11 14:15 ` Nicolas Goaziou 2018-05-12 8:12 ` Michael Brand 0 siblings, 1 reply; 21+ messages in thread From: Nicolas Goaziou @ 2018-05-11 14:15 UTC (permalink / raw To: Michael Brand; +Cc: Org Mode [-- Attachment #1: Type: text/plain, Size: 1047 bytes --] Michael Brand <michael.ch.brand@gmail.com> writes: > Do you mean here attached and updated as of today? I meant to attach it, but apparently forgot. I attach it here for other feedback. > Currently we disagree in that you suggest one bracket where I prefer > none for descriptive links and you suggest one bracket where I prefer > two for the other cases, see rendering examples and my reasons for raw > plain text in non-Org tools above. Indeed, we disagree. I find your suggestion not predictable enough. Sometimes square brackets appear, sometimes not... Besides, it doesn't solve the issue my suggestion was initially trying to solve. > If there would be an option to show 0 (current behavior), 1 (your > suggestion) or 2 brackets (new) everywhere I could use 2 as > a compromise. If the option 0, 1 or 2 would be individual for case > 1 and for case 3/4 that would of course be perfect at least for me. It's a matter of taste. Showing 2 square brackets doesn't bring much value, IMO. Anyway, we might need more feedback on the topic. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: partial link visibility --] [-- Type: text/x-diff, Size: 1347 bytes --] From 9e49be14b86a359cd4ea834763c697349eba0d2f Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou <mail@nicolasgoaziou.fr> Date: Fri, 11 May 2018 14:59:33 +0200 Subject: [PATCH] Add `partial' to `org-descriptive-link' * lisp/org.el (org-activate-links): Handle `partial' value. --- lisp/org.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 2cfe46697..bf1e19f36 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5914,8 +5914,17 @@ This includes angle, plain, and bracket links." ,(or (org-link-get-parameter type :display) 'org-link)) properties)) - (visible-start (or (match-beginning 4) (match-beginning 2))) - (visible-end (or (match-end 4) (match-end 2)))) + (visible-start + (pcase org-descriptive-links + (`nil start) + (`partial (or (match-beginning 3) + (1- (match-beginning 2)))) + (_ (or (match-beginning 4) (match-beginning 2))))) + (visible-end + (pcase org-descriptive-links + (`nil end) + (`partial (or (match-end 3) (1+ (match-end 2)))) + (_ (or (match-end 4) (match-end 2)))))) (add-text-properties start visible-start hidden) (add-text-properties visible-start visible-end properties) (add-text-properties visible-end end hidden) -- 2.17.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-11 14:15 ` Nicolas Goaziou @ 2018-05-12 8:12 ` Michael Brand 2018-05-17 16:17 ` Michael Brand 0 siblings, 1 reply; 21+ messages in thread From: Michael Brand @ 2018-05-12 8:12 UTC (permalink / raw To: Nicolas Goaziou; +Cc: Org Mode [-- Attachment #1: Type: text/plain, Size: 327 bytes --] Hi Nicolas Thank you for the patch. I changed it (attached) to something that preserves org-toggle-link-display and allows more different configs for more different usages, please see the docstring of org-link-brackets. I tried it out with org-toggle-link-display and for org-link-brackets '(0 0), '(1 1) and '(0 2). Michael [-- Attachment #2: org-link-brackets.diff --] [-- Type: application/octet-stream, Size: 2064 bytes --] diff --git a/lisp/org.el b/lisp/org.el index 2cfe466..261d5ed 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -1897,6 +1897,28 @@ You can interactively set the value of this variable by calling :group 'org-link :type 'boolean) +(defcustom org-link-brackets '(0 0) + "Number of bracket pairs shown while `org-descriptive-links' is t. + +The first element is for descriptive links and can be 0 or 1. The +second element is for non-descriptive links and can be 0, 1 or 2. + +Value examples: + +'(1 1) can be useful for a better navigation and editing +experience at the beginning and end of a link. + +'(0 2) can be useful to get the same table alignment and +paragraph filling for non-descriptive links as in Org also in +non-Org tools. For descriptive links this is not possible, +therefore in this example the default 0." + + ;; TODO: Type and value check for customization. + ;; TODO: Just a list was simple for a first step but is possibly not + ;; state of the art for such a config. + + :group 'org-link) + (defcustom org-link-file-path-type 'adaptive "How the path name in file links should be stored. Valid values are: @@ -5914,8 +5936,19 @@ This includes angle, plain, and bracket links." ,(or (org-link-get-parameter type :display) 'org-link)) properties)) - (visible-start (or (match-beginning 4) (match-beginning 2))) - (visible-end (or (match-end 4) (match-end 2)))) + (visible-start + (or + ;; For descriptive links. + (match-beginning + (if (zerop (car org-link-brackets)) 4 3)) + ;; For non-descriptive links. + (- (match-beginning 2) (cadr org-link-brackets)))) + (visible-end + (or + ;; For descriptive links. + (match-end (if (zerop (car org-link-brackets)) 4 3)) + ;; For non-descriptive links. + (+ (match-end 2) (cadr org-link-brackets))))) (add-text-properties start visible-start hidden) (add-text-properties visible-start visible-end properties) (add-text-properties visible-end end hidden) ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: Link "bracket-types" 2018-05-12 8:12 ` Michael Brand @ 2018-05-17 16:17 ` Michael Brand 0 siblings, 0 replies; 21+ messages in thread From: Michael Brand @ 2018-05-17 16:17 UTC (permalink / raw To: Org Mode Hi all On Sat, May 12, 2018 at 10:12 AM, Michael Brand <michael.ch.brand@gmail.com> wrote: > Thank you for the patch. I changed it (attached) to something that > preserves org-toggle-link-display and allows more different configs > for more different usages, please see the docstring of > org-link-brackets. I tried it out with org-toggle-link-display and for > org-link-brackets '(0 0), '(1 1) and '(0 2). Another use case for playing with org-link-brackets config: In my opinion the underline in the org-link face makes descriptive links with many words less readable. Currently I try out underline turned off. To compensate for the missing indication of beginning and end of adjacent descriptive links I changed org-link-brackets from my previous '(0 2) to '(1 2) to get 1 bracket pair around descriptive links. For those interested in readability: Put the following without the #-lines in an empty Org buffer (with the default face for org-link and underline) and try to read as fast as possible. #+begin_example ---- 8< ---- cut here ---- 8< ---- 1) TIHS IS RAEADLBE BCUSEAE TEH HUAMN MNID DEOS NTO RAED ERVEY LTETER BY ISTLEF, BTU TEH WROD AS A WLOHE 2) [[http://example.com][Tihs is raeadlbe bcuseae teh huamn mnid deos nto raed ervey lteter by istlef, btu teh wrod as a wlohe]] 3) _Tihs is raeadlbe bcuseae teh huamn mnid deos nto raed ervey lteter by istlef, btu teh wrod as a wlohe_ 4) Tihs is raeadlbe bcuseae teh huamn mnid deos nto raed ervey lteter by istlef, btu teh wrod as a wlohe ---- 8< ---- cut here ---- 8< ---- #+end_example To my understanding underline and UPPERCASE decrease readability because they affect the bouma. http://en.wikipedia.org/wiki/Bouma michael ʅǝɐɥɔᴉɯ ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2018-05-17 16:17 UTC | newest] Thread overview: 21+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-05-10 6:08 Link "bracket-types" Michael Brand 2018-05-10 8:14 ` Nicolas Goaziou 2018-05-10 8:32 ` Eric S Fraga 2018-05-11 12:34 ` Nicolas Goaziou 2018-05-11 13:20 ` Eric S Fraga 2018-05-10 9:41 ` Michael Brand 2018-05-10 12:44 ` Nicolas Goaziou 2018-05-10 13:23 ` Michael Brand 2018-05-10 13:33 ` Nicolas Goaziou 2018-05-10 14:29 ` Michael Brand 2018-05-10 16:27 ` Nicolas Goaziou 2018-05-10 19:58 ` Samuel Wales 2018-05-12 23:35 ` Samuel Wales 2018-05-13 11:10 ` Eric S Fraga 2018-05-10 19:59 ` Michael Brand 2018-05-11 0:22 ` Nicolas Goaziou 2018-05-11 13:10 ` Nicolas Goaziou 2018-05-11 13:55 ` Michael Brand 2018-05-11 14:15 ` Nicolas Goaziou 2018-05-12 8:12 ` Michael Brand 2018-05-17 16:17 ` Michael Brand
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.