all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: function to copy org buffer substring with link description only
       [not found] <mailman.1527.1449434757.31583.help-gnu-emacs@gnu.org>
@ 2015-12-09 19:57 ` Gene
  2015-12-29 21:28   ` #org #annotate #lentic.el #annotate.el -- was " Gene
  0 siblings, 1 reply; 5+ messages in thread
From: Gene @ 2015-12-09 19:57 UTC (permalink / raw)
  To: help-gnu-emacs

On Sunday, December 6, 2015 at 3:46:00 PM UTC-5, Paul wrote:
> Hallo people.
> 
> (buffer-substring-no-properties (point) (mark)) on some part of an org 
> buffer that contains a link returns the following example:
> 
> "while [[(some-link)][description]] does not"
> 
> 
> Do You know a ready to use function that would return the following?:
> 
> "while description does not"
> 
> best regards,
> Paul

I think you might want to consider how you'd use this in practice.
It seems that you want to perform a destructive, non-restorable edit, rather than using two views of the same data via lentic or such.
As the string returned by the example contains the ASCII text of/for an org link this string can be parsed via split-string for both "[[" and "]]" to find beginning and end of the link to use as point and mark.
Or -- if you think about it -- searching for "][" should drop the cursor/point at the start of the description string of interest which ends at "]]"

As a general pointer/clue, `elt' is your friend because it operates on any sequence ... both strings and vectors in your case.
The structure of an org-mode link is a vector containing two vectors.
The description can be stripped from the vector either as a vector or while it's embedded in the string produced from the substring function.

The function which generates an org link is org-make-link-string.
Perhaps if you read the source for that function you will discover how links are assembled and therein obtain insights into how to disassemble them.

Here's a snippet of some code I crafted while going the other way ... starting with an URL then generating an org-mode link:

(defun 
  ddg2org-link 
 (
  lst ; the argument
 )
 "For every duckduckgo URL in lst produce an org-mode link"
 (interactive)
 (mapcar
 (lambda (ddg-URL)
    (org-make-link-string 
        ddg-URL              ; LINK
        (mapconcat
           #'identity                    ; FUNCTION 
           (split-string 
            (cadr                   ;\
              (split-string         ; \
                ddg-URL ; STRING    ;  > ; SEQUENCE 
               "?q="    ; SEPARATOR ; /
              )                     ;/
             )
             "%20"                       ; SEPARATOR for split-string
            );split-string
           " "                           ; SEPARATOR for mapconcat
        ) ; mapconcat
   ) ;org-make-link-string
  ) ; lambda
  lst
 );mapcar
)

; test it with a list of ddg URLs
(ddg2org-link 
'(
  "https://duckduckgo.com/html/?q=monsters%20are%20real%20stephen%20king"
  "https://duckduckgo.com/html/?q=love%20map"
))


I hope these clues help you think your way through to a workable solution.

Cheers!


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

* #org #annotate #lentic.el #annotate.el -- was Re: function to copy org buffer substring with link description only
  2015-12-09 19:57 ` function to copy org buffer substring with link description only Gene
@ 2015-12-29 21:28   ` Gene
  2015-12-30  1:39     ` Drew Adams
  2016-01-07 21:15     ` Phillip Lord
  0 siblings, 2 replies; 5+ messages in thread
From: Gene @ 2015-12-29 21:28 UTC (permalink / raw)
  To: help-gnu-emacs

This problem of only wanting half of the info encapsulated in an org link resulted in some possibly-valuable follow-on thoughts.

A few days ago I was familiarizing myself with annotate.el which allows a file of annotations to be associated with a given file without that file being modified.
Then today, I noticed org-cliplink

 org-cliplink       20151229.... available  melpa      insert org-mode links 

It dawned on me that whether one only wants the URL of a link XOR the description a link for one's immediate purposes one MIGHT want the otherwise discarded information to be saved/retained in an annotation file -- perhaps by functions within annotation.el -- for possible future use, for use in a bibliography of sorts, etc.

Also, given the ability to use lenticular text with emacs it might be nice if the target text created by removing the non-descriptive part of an org link could be treated as lenticular text of sorts wherein the description would used as if literal text while the URL were retained in some way as a silent, invisible partner.

Also, the original problem seems ready-made for an org export operation capable of producing plain text.

Just some food for thought for developers.

Cheers!


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

* RE: #org #annotate #lentic.el #annotate.el -- was Re: function to copy org buffer substring with link description only
  2015-12-29 21:28   ` #org #annotate #lentic.el #annotate.el -- was " Gene
@ 2015-12-30  1:39     ` Drew Adams
  2016-01-07 21:15     ` Phillip Lord
  1 sibling, 0 replies; 5+ messages in thread
From: Drew Adams @ 2015-12-30  1:39 UTC (permalink / raw)
  To: Gene, help-gnu-emacs

> A few days ago I was familiarizing myself with annotate.el which allows a
> file of annotations to be associated with a given file without that file
> being modified.

[OT] FWIW, you can also bookmark a file (including in multiple places),
and a bookmark can have an annotation.  That gives you any number of
annotations for a file, each addressed directly.

If you use Bookmark+ then a bookmark annotation is in Org mode by
default, and an annotation can itself be a pointer to a separate
Org file (as opposed to saving annotations along with the bookmarks
they annotate, in your bookmarks file).

http://www.emacswiki.org/emacs/BookmarkPlus



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

* Re: #org #annotate #lentic.el #annotate.el -- was Re: function to copy org buffer substring with link description only
  2015-12-29 21:28   ` #org #annotate #lentic.el #annotate.el -- was " Gene
  2015-12-30  1:39     ` Drew Adams
@ 2016-01-07 21:15     ` Phillip Lord
  2016-01-08  0:52       ` Gene Sullivan
  1 sibling, 1 reply; 5+ messages in thread
From: Phillip Lord @ 2016-01-07 21:15 UTC (permalink / raw)
  To: Gene; +Cc: help-gnu-emacs

Gene <gene.sullivan@gmail.com> writes:
> Also, given the ability to use lenticular text with emacs it might be nice if
> the target text created by removing the non-descriptive part of an org link
> could be treated as lenticular text of sorts wherein the description would
> used as if literal text while the URL were retained in some way as a silent,
> invisible partner.


I am not 100% sure what you want here; are you after something that is
just a visualisation? I thought that org does that already -- i.e. it
just makes the link invisible and leaves just the description.

Phil



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

* Re: #org #annotate #lentic.el #annotate.el -- was Re: function to copy org buffer substring with link description only
  2016-01-07 21:15     ` Phillip Lord
@ 2016-01-08  0:52       ` Gene Sullivan
  0 siblings, 0 replies; 5+ messages in thread
From: Gene Sullivan @ 2016-01-08  0:52 UTC (permalink / raw)
  To: Phillip Lord; +Cc: help-gnu-emacs

What I wanted is a means for helping those with an org-mode link to retain
ALL/both data rather than jettisoning either the URL or the description.

There seems a chasm between an org-mode file and each of the various
end-goal re-uses and/or destination file formats available via `export'.
I was attempting to brainstorm ways of preserving both data and the
relations between data within the org-mode file so it can be available for
possible future use ... while allowing someone hell-bent on only ONE use --
in a surface-structural `visualization' -- to use only the portions exposed
without destroying or discarding the portions of no immediate use.



On Thu, Jan 7, 2016 at 4:15 PM, Phillip Lord <phillip.lord@russet.org.uk>
wrote:

> Gene <gene.sullivan@gmail.com> writes:
> > Also, given the ability to use lenticular text with emacs it might be
> nice if
> > the target text created by removing the non-descriptive part of an org
> link
> > could be treated as lenticular text of sorts wherein the description
> would
> > used as if literal text while the URL were retained in some way as a
> silent,
> > invisible partner.
>
>
> I am not 100% sure what you want here; are you after something that is
> just a visualisation? I thought that org does that already -- i.e. it
> just makes the link invisible and leaves just the description.
>
> Phil
>


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

end of thread, other threads:[~2016-01-08  0:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1527.1449434757.31583.help-gnu-emacs@gnu.org>
2015-12-09 19:57 ` function to copy org buffer substring with link description only Gene
2015-12-29 21:28   ` #org #annotate #lentic.el #annotate.el -- was " Gene
2015-12-30  1:39     ` Drew Adams
2016-01-07 21:15     ` Phillip Lord
2016-01-08  0:52       ` Gene Sullivan

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.