[-- Attachment #1: Type: text/plain, Size: 161 bytes --] Hi all, Is it just me or is there no quick way to remove the link from some hyperlinked text? If so, please consider this a feature request ;-) Regards, Adam [-- Attachment #2: Type: text/html, Size: 252 bytes --]
Adam Spiers <orgmode@adamspiers.org> writes: Try this: (defun unlinkify () "replace an org-link with the path, or description." (interactive) (let ((eop (org-element-context))) (when (eq 'link (car eop)) (message "%s" eop) (let* ((start (org-element-property :begin eop)) (end (org-element-property :end eop)) (contents-begin (org-element-property :contents-begin eop)) (contents-end (org-element-property :contents-end eop)) (path (org-element-property :path eop)) (desc (and contents-begin contents-end (buffer-substring contents-begin contents-end)))) (setf (buffer-substring start end) (or desc path)))))) > Hi all, > > Is it just me or is there no quick way to remove the link from some > hyperlinked text? If so, please consider this a feature request ;-) > > Regards, > Adam > -- ----------------------------------- John Kitchin Professor Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 http://kitchingroup.cheme.cmu.edu
On Thu, Nov 06, 2014 at 08:30:08PM -0500, John Kitchin wrote:
> Adam Spiers <orgmode@adamspiers.org> writes:
> > Is it just me or is there no quick way to remove the link from some
> > hyperlinked text? If so, please consider this a feature request ;-)
>
> Try this:
>
> (defun unlinkify ()
> "replace an org-link with the path, or description."
> (interactive)
> (let ((eop (org-element-context)))
> (when (eq 'link (car eop))
> (message "%s" eop)
> (let* ((start (org-element-property :begin eop))
> (end (org-element-property :end eop))
> (contents-begin (org-element-property :contents-begin eop))
> (contents-end (org-element-property :contents-end eop))
> (path (org-element-property :path eop))
> (desc (and contents-begin
> contents-end
> (buffer-substring contents-begin contents-end))))
> (setf (buffer-substring start end) (or desc path))))))
Thanks, that worked great! Can I suggest you submit this for
inclusion in org itself? :-) I guess it would need to be called
`org-unlinkify'.
Hello, Adam Spiers <orgmode@adamspiers.org> writes: > On Thu, Nov 06, 2014 at 08:30:08PM -0500, John Kitchin wrote: >> Adam Spiers <orgmode@adamspiers.org> writes: >> > Is it just me or is there no quick way to remove the link from some >> > hyperlinked text? If so, please consider this a feature request ;-) >> >> Try this: >> >> (defun unlinkify () >> "replace an org-link with the path, or description." >> (interactive) >> (let ((eop (org-element-context))) >> (when (eq 'link (car eop)) (when (eq (org-element-type eop) 'link) >> (message "%s" eop) >> (let* ((start (org-element-property :begin eop)) >> (end (org-element-property :end eop)) >> (contents-begin (org-element-property :contents-begin eop)) >> (contents-end (org-element-property :contents-end eop)) >> (path (org-element-property :path eop)) >> (desc (and contents-begin >> contents-end >> (buffer-substring contents-begin contents-end)))) >> (setf (buffer-substring start end) (or desc path)))))) > > Thanks, that worked great! Can I suggest you submit this for > inclusion in org itself? :-) I guess it would need to be called > `org-unlinkify'. FWIW, I don't think it is useful enough for inclusion in core. It could go in Worg however. Regards, -- Nicolas Goaziou
On Thu, Dec 04, 2014 at 06:07:53PM +0100, Nicolas Goaziou wrote:
> Adam Spiers <orgmode@adamspiers.org> writes:
> > On Thu, Nov 06, 2014 at 08:30:08PM -0500, John Kitchin wrote:
> >> Adam Spiers <orgmode@adamspiers.org> writes:
> >> > Is it just me or is there no quick way to remove the link from some
> >> > hyperlinked text? If so, please consider this a feature request ;-)
> >>
> >> Try this:
> >>
> >> (defun unlinkify ()
> >> "replace an org-link with the path, or description."
> >> (interactive)
> >> (let ((eop (org-element-context)))
> >> (when (eq 'link (car eop))
>
> (when (eq (org-element-type eop) 'link)
>
> >> (message "%s" eop)
> >> (let* ((start (org-element-property :begin eop))
> >> (end (org-element-property :end eop))
> >> (contents-begin (org-element-property :contents-begin eop))
> >> (contents-end (org-element-property :contents-end eop))
> >> (path (org-element-property :path eop))
> >> (desc (and contents-begin
> >> contents-end
> >> (buffer-substring contents-begin contents-end))))
> >> (setf (buffer-substring start end) (or desc path))))))
> >
> > Thanks, that worked great! Can I suggest you submit this for
> > inclusion in org itself? :-) I guess it would need to be called
> > `org-unlinkify'.
>
> FWIW, I don't think it is useful enough for inclusion in core.
Why not? Or perhaps I should ask: how is it determined whether
something's useful enough for core? :-)
Adam Spiers <orgmode@adamspiers.org> writes: >> FWIW, I don't think it is useful enough for inclusion in core. > > Why not? Because we cannot possibly stuff everything related to Org in core. The function saves a few keystrokes, but considering how often I expect it to be used, the benefit from using it seems rather negligible. OTOH, putting it on Worg gives it some exposure, so it isn't lost in the mailing list archives. Of course, this is all IMO, and other developers, or Bastien, could disagree. > Or perhaps I should ask: how is it determined whether > something's useful enough for core? :-) As for myself, the following works surprisingly well in various situations: (defun ngz-answering-helper (&optional from-wife-p) (cond (from-wife-p 'yes) ((= (random 10) 0) 'yes) (t 'no))) Regards,