emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bastienguerry@googlemail.com>
To: James TD Smith <ahktenzero@mohorovi.cc>
Cc: emacs-orgmode@gnu.org
Subject: Re: [misc-new-features 4/5] Allow org-insert-link to check the X clipboard and the Emacs kill-ring for links, as well as the stored links. This makes getting URLs into org from a browser much easier, as you don't have to paste the URL into the minibuffer to insert a link.
Date: Fri, 17 Jul 2009 19:20:36 +0200	[thread overview]
Message-ID: <87fxcv4463.fsf@bzg.ath.cx> (raw)
In-Reply-To: <1247473682-23338-5-git-send-email-ahktenzero@mohorovi.cc> (James TD Smith's message of "Mon, 13 Jul 2009 09:28:01 +0100")

Hi James,

I'm still hesitating for this patch.  

Something I like when I insert a link is that I get rid of it, it
doesn't stay in org-stored-links (unless explicitely told so).  If
org-insert-links accepts links from the kill-ring and/or from the
clipboard, then some links will stay.  More generally, the source of
links becomes a bit "unstable".  

I understand the purpose and I see how it could be useful but I would
need other advice on this.

Thanks!

James TD Smith <ahktenzero@mohorovi.cc> writes:

> You can customise `org-link-check-clipboards' to check either the X clipboards
> or kill-ring only, or both, or none. If you have the interprogram-cut/paste
> functions set, you probably only want to use the kill-ring only.
> ---
>  lisp/ChangeLog |    5 ++++
>  lisp/org.el    |   66 ++++++++++++++++++++++++++++++++++++++++---------------
>  2 files changed, 53 insertions(+), 18 deletions(-)
>
> diff --git a/lisp/ChangeLog b/lisp/ChangeLog
> index 9ce7a17..662a585 100755
> --- a/lisp/ChangeLog
> +++ b/lisp/ChangeLog
> @@ -14,6 +14,11 @@
>  	(org-tags-sort-function): Add custom declaration for tags
>  	sorting function.
>  	(org-set-tags): Sort tags if org-tags-sort-function is set
> +	(org-link-check-clipboards): Add a custom option for
> +	clipboard link checking
> +	(org-insert-link): If enabled, check the X clipboard and emacs
> +	kill ring for strings which look like links, and include them in
> +	the stored links to select from.
>  
>  2009-07-08  Carsten Dominik  <carsten.dominik@gmail.com>
>  
> diff --git a/lisp/org.el b/lisp/org.el
> index 854d09c..47fb0b6 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -1024,6 +1024,15 @@ to use."
>    :group 'org-link
>    :type 'function)
>  
> +(defcustom org-link-check-clipboards nil
> +  "Should org-insert-link check clipboards for links"
> +  :group 'org-link
> +  :type '(choice
> +	  (const :tag "Just stored links" nil)
> +	  (const :tag "The X11 clipboards" x)
> +	  (const :tag "The Emacs kill-ring" emacs)
> +	  (const :tag "Both" both)))
> +
>  (defgroup org-link-store nil
>    "Options concerning storing links in Org-mode."
>    :tag "Org Store Link"
> @@ -7323,6 +7332,7 @@ used as the link location instead of reading one interactively."
>  	 (desc region)
>  	 tmphist ; byte-compile incorrectly complains about this
>  	 (link link-location)
> +	 (stored-links org-stored-links)
>  	 entry file all-prefixes)
>      (cond
>       (link-location) ; specified by arg, just use it.
> @@ -7342,26 +7352,46 @@ used as the link location instead of reading one interactively."
>       ((member complete-file '((4) (16)))
>        ;; Completing read for file names.
>        (setq link (org-file-complete-link complete-file)))
> -     (t
> -      ;; Read link, with completion for stored links.
> -      (with-output-to-temp-buffer "*Org Links*"
> -	(princ "Insert a link.
> +     (t ;; Read link, with completion for stored links.
> +      ;;Check clipboards/kill ring for links
> +      (when org-link-check-clipboards
> +	(setq stored-links
> +	      (append stored-links
> +		      (mapcar
> +		       (lambda (x) (list x "Link from clipboard"))
> +		       (remove
> +			nil
> +			(remove-duplicates
> +			 (mapcar
> +			  (lambda (x)
> +			    (when (and x (string-match org-link-types-re x)) x))
> +			  (append (when
> +				      (or (eq org-link-check-clipboards 'x)
> +					  (eq org-link-check-clipboards 'both))
> +				    (list (org-get-x-clipboard 'PRIMARY)
> +					  (org-get-x-clipboard 'CLIPBOARD)
> +					  (org-get-x-clipboard 'SECONDARY)))
> +				  (when
> +				      (or (eq org-link-check-clipboards 'emacs)
> +					  (eq org-link-check-clipboards 'both))
> +				    (mapcar 'org-no-properties kill-ring))))))))))
> +	(with-output-to-temp-buffer "*Org Links*"
> +	  (princ "Insert a link.
>  Use TAB to complete link prefixes, then RET for type-specific completion support\n")
> -	(when org-stored-links
> -	  (princ "\nStored links are available with <up>/<down> or M-p/n (most recent with RET):\n\n")
> -	  (princ (mapconcat
> -		  (lambda (x)
> -		    (if (nth 1 x) (concat (car x) " (" (nth 1 x) ")") (car x)))
> -		  (reverse org-stored-links) "\n"))))
> -      (let ((cw (selected-window)))
> -	(select-window (get-buffer-window "*Org Links*"))
> +	  (when stored-links
> +	    (princ "\nStored links are available with <up>/<down> or M-p/n (most recent with RET):\n\n")
> +	    (princ (mapconcat
> +		    (lambda (x)
> +		      (if (nth 1 x) (concat (car x) " (" (nth 1 x) ")") (car x)))
> +		    (reverse stored-links) "\n"))))
> +	(let ((cw (selected-window)))
> +	  (select-window (get-buffer-window "*Org Links*"))
>  	(setq truncate-lines t)
>  	(unless (pos-visible-in-window-p (point-max))
>  	  (org-fit-window-to-buffer))
>  	(and (window-live-p cw) (select-window cw)))
>        ;; Fake a link history, containing the stored links.
> -      (setq tmphist (append (mapcar 'car org-stored-links)
> -			    org-insert-link-history))
> +      (setq tmphist (append (mapcar 'car stored-links) org-insert-link-history))
>        (setq all-prefixes (append (mapcar 'car org-link-abbrev-alist-local)
>  				 (mapcar 'car org-link-abbrev-alist)
>  				 org-link-types))
> @@ -7375,7 +7405,7 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
>  			     all-prefixes)
>  		     nil nil nil
>  		     'tmphist
> -		     (or (car (car org-stored-links))))))
> +		     (or (car (car stored-links))))))
>  	    (if (or (member link all-prefixes)
>  		    (and (equal ":" (substring link -1))
>  			 (member (substring link 0 -1) all-prefixes)
> @@ -8729,8 +8759,8 @@ This function can be used in a hook."
>  ;;;; Completion
>  
>  (defconst org-additional-option-like-keywords
> -  '("BEGIN_HTML"  "END_HTML"  "HTML:" "ATTR_HTML" 
> -    "BEGIN_DocBook"  "END_DocBook"  "DocBook:" "ATTR_DocBook" 
> +  '("BEGIN_HTML"  "END_HTML"  "HTML:" "ATTR_HTML"
> +    "BEGIN_DocBook"  "END_DocBook"  "DocBook:" "ATTR_DocBook"
>      "BEGIN_LaTeX" "END_LaTeX" "LaTeX:" "LATEX_HEADER:"  "ATTR_LaTeX"
>      "BEGIN:" "END:"
>      "ORGTBL" "TBLFM:" "TBLNAME:"
> @@ -15842,7 +15872,7 @@ which make use of the date at the cursor."
>    (org-set-local 'comment-start-skip "^#+[ \t]*")
>    (org-set-local 'paragraph-separate "\f\\|\\*+ \\|[ 	]*$\\|[ \t]*[:|]")
>    ;; The paragraph starter includes hand-formatted lists.
> -  (org-set-local 
> +  (org-set-local
>     'paragraph-start
>     (concat
>      "\f" "\\|"

-- 
 Bastien

  parent reply	other threads:[~2009-07-17 17:20 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-13  8:27 Working on org again James TD Smith
2009-07-13  8:27 ` [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA James TD Smith
2009-07-13  8:27   ` [misc-new-features 2/5] Bugfixes, documentation and custom options for org-checklist James TD Smith
2009-07-13  8:28     ` [misc-new-features 3/5] Add an option to sort tags automatically James TD Smith
2009-07-13  8:28       ` [misc-new-features 4/5] Allow org-insert-link to check the X clipboard and the Emacs kill-ring for links, as well as the stored links. This makes getting URLs into org from a browser much easier, as you don't have to paste the URL into the minibuffer to insert a link James TD Smith
2009-07-13  8:28         ` [misc-new-features 5/5] Fix a problem I was having with plots using a script. Org-plot was deleting the data file before gnuplot read it in. I've moved the deletion of the temporary data file to an idle timer, which has fixed the problem James TD Smith
2009-07-13 11:56           ` Bernt Hansen
2009-07-14 11:57           ` Bastien
2009-07-17 17:03           ` Bastien
2009-07-13 11:55         ` [misc-new-features 4/5] Allow org-insert-link to check the X clipboard and the Emacs kill-ring for links, as well as the stored links. This makes getting URLs into org from a browser much easier, as you don't have to paste the URL into the minibuffer to insert a link Bernt Hansen
2009-07-13 12:13           ` [misc-new-features 4/5] extra long subject lines James TD Smith
2009-07-13 15:35             ` Bernt Hansen
2009-07-14 12:07         ` [misc-new-features 4/5] Allow org-insert-link to check the X clipboard and the Emacs kill-ring for links, as well as the stored links. This makes getting URLs into org from a browser much easier, as you don't have to paste the URL into the minibuffer to insert a link Bastien
2009-07-17 17:20         ` Bastien [this message]
2009-07-14 11:59       ` [misc-new-features 3/5] Add an option to sort tags automatically Bastien
2009-07-14 16:01         ` James TD Smith
2009-07-17 17:04           ` Bastien
2009-07-17 16:38       ` Bastien
2009-07-14 12:09     ` [misc-new-features 2/5] Bugfixes, documentation and custom options for org-checklist Bastien
2009-07-14  8:52       ` James TD Smith
2009-08-03 14:47     ` Carsten Dominik
2009-08-03 21:17       ` James TD Smith
2009-07-14 11:48   ` [misc-new-features 1/5] Add two new special properties, SINCE and SINCE_IA Bastien
2009-07-14 17:44     ` James TD Smith
2009-07-17 16:55   ` Bastien
2009-07-17 18:22     ` James TD Smith
2009-07-18  9:35       ` Bastien
2009-08-27 15:50         ` Manish
2009-08-28 17:59           ` James TD Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fxcv4463.fsf@bzg.ath.cx \
    --to=bastienguerry@googlemail.com \
    --cc=ahktenzero@mohorovi.cc \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).