emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* what do do when multiple functions store a link
@ 2021-01-02 13:49 John Kitchin
  2021-01-02 14:37 ` Daniele Nicolodi
  2021-01-02 22:13 ` [PATCH] ol: Avoid initial input when completing function for storing link Kyle Meyer
  0 siblings, 2 replies; 6+ messages in thread
From: John Kitchin @ 2021-01-02 13:49 UTC (permalink / raw)
  To: org-mode-email

[-- Attachment #1: Type: text/plain, Size: 1014 bytes --]

Recently I have had an issue where multiple functions may store a link,
e.g. to a bibtex entry.

In this case, org-mode seems to prompt me to ask which function to store
the link with, with an initial input of the first function, which masks all
the options that are available. This happens inside org-store-link in ol.el
at line 1495 for me. in

(apply #'org-link-store-props
(cdr (assoc-string
      (completing-read
"Which function for creating the link? "
(mapcar #'car results-alist)
nil t (symbol-name name))
      results-alist)))

because of the (symbol-name name).

Is there an easy way to avoid this, or to modify the order of the functions
used? I want to see all the options for storing, or better, to just store
them all and let me choose later when I use org-insert-link.

John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

[-- Attachment #2: Type: text/html, Size: 2682 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: what do do when multiple functions store a link
  2021-01-02 13:49 what do do when multiple functions store a link John Kitchin
@ 2021-01-02 14:37 ` Daniele Nicolodi
  2021-01-02 14:55   ` John Kitchin
  2021-01-02 22:13 ` [PATCH] ol: Avoid initial input when completing function for storing link Kyle Meyer
  1 sibling, 1 reply; 6+ messages in thread
From: Daniele Nicolodi @ 2021-01-02 14:37 UTC (permalink / raw)
  To: John Kitchin, org-mode-email

On 02/01/2021 14:49, John Kitchin wrote:
> Recently I have had an issue where multiple functions may store a link,
> e.g. to a bibtex entry. 
>  
> In this case, org-mode seems to prompt me to ask which function to store
> the link with, with an initial input of the first function, which masks
> all the options that are available. This happens
> inside |org-store-link| in ol.el at line 1495 for me. in
> 
> (apply #'org-link-store-props
> (cdr (assoc-string
>       (completing-read
> "Which function for creating the link? "
> (mapcar #'car results-alist)
> nil t (symbol-name name))
>       results-alist))) 
> 
> because of the (symbol-name name).
>  
> Is there an easy way to avoid this, or to modify the order of the
> functions used? I want to see all the options for storing, or better, to
> just store them all and let me choose later when I use org-insert-link.

I have the exact same problem. I think it comes from having org-bibtex
and org-ref loaded at the same time. I haven't investigated a possible
solution.

Cheers,
Dan


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: what do do when multiple functions store a link
  2021-01-02 14:37 ` Daniele Nicolodi
@ 2021-01-02 14:55   ` John Kitchin
  0 siblings, 0 replies; 6+ messages in thread
From: John Kitchin @ 2021-01-02 14:55 UTC (permalink / raw)
  To: Daniele Nicolodi; +Cc: org-mode-email

[-- Attachment #1: Type: text/plain, Size: 1822 bytes --]

Here is a very grungy solution:

(defun scimax-store-link-advice (orig-fun &rest args)
  (cl-letf (((symbol-function 'symbol-name)
	     (lambda (_)
	       "")))
    (apply orig-fun args)))

(advice-add 'org-store-link :around 'scimax-store-link-advice)

It works by temporarily redefining symbol-name to return an empty string.
It's only redeeming qualities are 1) it works, 2) you don't have to modify
the org src code!

John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Sat, Jan 2, 2021 at 9:37 AM Daniele Nicolodi <daniele@grinta.net> wrote:

> On 02/01/2021 14:49, John Kitchin wrote:
> > Recently I have had an issue where multiple functions may store a link,
> > e.g. to a bibtex entry.
> >
> > In this case, org-mode seems to prompt me to ask which function to store
> > the link with, with an initial input of the first function, which masks
> > all the options that are available. This happens
> > inside |org-store-link| in ol.el at line 1495 for me. in
> >
> > (apply #'org-link-store-props
> > (cdr (assoc-string
> >       (completing-read
> > "Which function for creating the link? "
> > (mapcar #'car results-alist)
> > nil t (symbol-name name))
> >       results-alist)))
> >
> > because of the (symbol-name name).
> >
> > Is there an easy way to avoid this, or to modify the order of the
> > functions used? I want to see all the options for storing, or better, to
> > just store them all and let me choose later when I use org-insert-link.
>
> I have the exact same problem. I think it comes from having org-bibtex
> and org-ref loaded at the same time. I haven't investigated a possible
> solution.
>
> Cheers,
> Dan
>

[-- Attachment #2: Type: text/html, Size: 2924 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] ol: Avoid initial input when completing function for storing link
  2021-01-02 13:49 what do do when multiple functions store a link John Kitchin
  2021-01-02 14:37 ` Daniele Nicolodi
@ 2021-01-02 22:13 ` Kyle Meyer
  2021-01-05  5:16   ` Kyle Meyer
  1 sibling, 1 reply; 6+ messages in thread
From: Kyle Meyer @ 2021-01-02 22:13 UTC (permalink / raw)
  To: John Kitchin; +Cc: org-mode-email

John Kitchin writes:

> Recently I have had an issue where multiple functions may store a link,
> e.g. to a bibtex entry.
>
> In this case, org-mode seems to prompt me to ask which function to store
> the link with, with an initial input of the first function, which masks all
> the options that are available. This happens inside org-store-link in ol.el
> at line 1495 for me. in
>
> (apply #'org-link-store-props
> (cdr (assoc-string
>       (completing-read
> "Which function for creating the link? "
> (mapcar #'car results-alist)
> nil t (symbol-name name))
>       results-alist)))
>
> because of the (symbol-name name).
>
> Is there an easy way to avoid this, or to modify the order of the functions
> used? I want to see all the options for storing, or better, to just store
> them all and let me choose later when I use org-insert-link.

The "or better" sounds reasonable.  Perhaps someone will attempt that,
but in the meantime I think just avoiding the discouraged/mostly
deprecated INITIAL-INPUT argument would be a good improvement.

-- >8 --
Subject: [PATCH] ol: Avoid initial input when completing function for storing
 link

* lisp/ol.el (org-store-link): Use completing-read's DEF argument
rather than INITIAL-INPUT, which is discouraged (see Elisp manual) and
may hide the other choices depending on the completion framework.

Reported-by: John Kitchin <jkitchin@andrew.cmu.edu>
Ref: https://orgmode.org/list/CAJ51ETqO9A8mE0W3pgU2cFzaZsESdYXAV0X-8veY+_V9AwPHdQ@mail.gmail.com
---
 lisp/ol.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index 5ba813142..cf105786f 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1496,9 +1496,9 @@ (defun org-store-link (arg &optional interactive?)
 		  (apply #'org-link-store-props
 			 (cdr (assoc-string
 			       (completing-read
-				"Which function for creating the link? "
-				(mapcar #'car results-alist)
-				nil t (symbol-name name))
+                                (format "Store link with (default %s): " name)
+                                (mapcar #'car results-alist)
+                                nil t nil nil (symbol-name name))
 			       results-alist)))
 		  t))))
 	(setq link (plist-get org-store-link-plist :link))

base-commit: 291993888d7b6776d42a86facd26c8bc0f72e475
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] ol: Avoid initial input when completing function for storing link
  2021-01-02 22:13 ` [PATCH] ol: Avoid initial input when completing function for storing link Kyle Meyer
@ 2021-01-05  5:16   ` Kyle Meyer
  2021-04-25  3:38     ` Timothy
  0 siblings, 1 reply; 6+ messages in thread
From: Kyle Meyer @ 2021-01-05  5:16 UTC (permalink / raw)
  To: John Kitchin; +Cc: org-mode-email

Kyle Meyer writes:

> John Kitchin writes:
>
>> Is there an easy way to avoid this, or to modify the order of the functions
>> used? I want to see all the options for storing, or better, to just store
>> them all and let me choose later when I use org-insert-link.
>
> The "or better" sounds reasonable.  Perhaps someone will attempt that,
> but in the meantime I think just avoiding the discouraged/mostly
> deprecated INITIAL-INPUT argument would be a good improvement.
>
> -- >8 --
> Subject: [PATCH] ol: Avoid initial input when completing function for storing
>  link

Pushed (00b4de329).


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ol: Avoid initial input when completing function for storing link
  2021-01-05  5:16   ` Kyle Meyer
@ 2021-04-25  3:38     ` Timothy
  0 siblings, 0 replies; 6+ messages in thread
From: Timothy @ 2021-04-25  3:38 UTC (permalink / raw)
  To: emacs-orgmode


This was not marked as applied on updates.orgmode.org.
Doing so with the X-Woof-Patch header.

Kyle Meyer <kyle@kyleam.com> writes:

> Pushed (00b4de329).


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-04-25  3:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-02 13:49 what do do when multiple functions store a link John Kitchin
2021-01-02 14:37 ` Daniele Nicolodi
2021-01-02 14:55   ` John Kitchin
2021-01-02 22:13 ` [PATCH] ol: Avoid initial input when completing function for storing link Kyle Meyer
2021-01-05  5:16   ` Kyle Meyer
2021-04-25  3:38     ` Timothy

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).