* Function to return content of item @ 2017-05-07 23:04 Richard Parsons 2017-05-08 0:45 ` John Kitchin 0 siblings, 1 reply; 4+ messages in thread From: Richard Parsons @ 2017-05-07 23:04 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 299 bytes --] Hi there Is there a function that will give me the content of the current item? I mean simply the text of the whole item without its heading or properties drawer. It seems to me likely that such a function would exist, but I haven't been able to find it in the documentation. Many thanks Richard [-- Attachment #2: Type: text/html, Size: 405 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Function to return content of item 2017-05-07 23:04 Function to return content of item Richard Parsons @ 2017-05-08 0:45 ` John Kitchin [not found] ` <CAB+=1LFbo7_nysB2TfcrDHZ87bjdMCEGAg5zu38nOi78qEbJ8g@mail.gmail.com> 0 siblings, 1 reply; 4+ messages in thread From: John Kitchin @ 2017-05-08 0:45 UTC (permalink / raw) To: Richard Parsons; +Cc: emacs-orgmode I don't know of a function. Something like this may be what you want. not all elements have :contents-begin though (let ((el (org-element-context))) (buffer-substring-no-properties (org-element-property :contents-begin el) (org-element-property :contents-end el))) It also a little tricky to figure out what to do about subheadings. Do they count as content or not? Richard Parsons writes: > Hi there > > Is there a function that will give me the content of the current item? I > mean simply the text of the whole item without its heading or properties > drawer. > > It seems to me likely that such a function would exist, but I haven't been > able to find it in the documentation. > > Many thanks > Richard -- 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <CAB+=1LFbo7_nysB2TfcrDHZ87bjdMCEGAg5zu38nOi78qEbJ8g@mail.gmail.com>]
* Re: Function to return content of item [not found] ` <CAB+=1LFbo7_nysB2TfcrDHZ87bjdMCEGAg5zu38nOi78qEbJ8g@mail.gmail.com> @ 2017-05-08 15:05 ` John Kitchin 2017-05-08 17:19 ` Richard Parsons 0 siblings, 1 reply; 4+ messages in thread From: John Kitchin @ 2017-05-08 15:05 UTC (permalink / raw) To: Richard Parsons; +Cc: emacs-orgmode I think this is basically what you are looking for. (defun org-heading-content () (interactive) (let (bp ep) (setq bp (save-excursion (or (and (outline-previous-heading) (progn (org-end-of-meta-data) (point))) (point-min))) ep (save-excursion (or (and (outline-next-heading) (point)) (point-max)))) (buffer-substring-no-properties bp ep))) Richard Parsons writes: > John, many thanks for your reply. > > Regarding subheadings, I would only want the content of the current > sub-item, so if it is a subheading I only want the text from after the > subheading (and after its property drawer) up to the next heading (or the > end of the file). > > Also, when I run your code on a paragraph, I just get the contents from > that paragraph (rather than all paragraphs in that item). Maybe "item" is > the wrong work, is "node" better? > > Maybe I need to write some code using the org motion commands in order to > manually identify the region that I'm looking for. > > Many thanks > Richard > > > On Mon, May 8, 2017 at 1:45 AM, John Kitchin <jkitchin@andrew.cmu.edu> > wrote: > >> I don't know of a function. Something like this may be what you want. >> not all elements have :contents-begin though >> >> (let ((el (org-element-context))) >> (buffer-substring-no-properties >> (org-element-property :contents-begin el) >> (org-element-property :contents-end el))) >> >> >> It also a little tricky to figure out what to do about subheadings. Do >> they count as content or not? >> >> Richard Parsons writes: >> >> > Hi there >> > >> > Is there a function that will give me the content of the current item? I >> > mean simply the text of the whole item without its heading or properties >> > drawer. >> > >> > It seems to me likely that such a function would exist, but I haven't >> been >> > able to find it in the documentation. >> > >> > Many thanks >> > Richard >> >> >> -- >> 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 >> -- 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Function to return content of item 2017-05-08 15:05 ` John Kitchin @ 2017-05-08 17:19 ` Richard Parsons 0 siblings, 0 replies; 4+ messages in thread From: Richard Parsons @ 2017-05-08 17:19 UTC (permalink / raw) To: John Kitchin; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 2815 bytes --] That is very kind of you - many thanks indeed for your assistance. On Mon, May 8, 2017 at 4:05 PM, John Kitchin <jkitchin@andrew.cmu.edu> wrote: > I think this is basically what you are looking for. > > (defun org-heading-content () > (interactive) > (let (bp ep) > (setq bp (save-excursion > (or (and (outline-previous-heading) > (progn (org-end-of-meta-data) > (point))) > (point-min))) > ep (save-excursion > (or (and (outline-next-heading) (point)) > (point-max)))) > (buffer-substring-no-properties bp ep))) > > Richard Parsons writes: > > > John, many thanks for your reply. > > > > Regarding subheadings, I would only want the content of the current > > sub-item, so if it is a subheading I only want the text from after the > > subheading (and after its property drawer) up to the next heading (or the > > end of the file). > > > > Also, when I run your code on a paragraph, I just get the contents from > > that paragraph (rather than all paragraphs in that item). Maybe "item" is > > the wrong work, is "node" better? > > > > Maybe I need to write some code using the org motion commands in order to > > manually identify the region that I'm looking for. > > > > Many thanks > > Richard > > > > > > On Mon, May 8, 2017 at 1:45 AM, John Kitchin <jkitchin@andrew.cmu.edu> > > wrote: > > > >> I don't know of a function. Something like this may be what you want. > >> not all elements have :contents-begin though > >> > >> (let ((el (org-element-context))) > >> (buffer-substring-no-properties > >> (org-element-property :contents-begin el) > >> (org-element-property :contents-end el))) > >> > >> > >> It also a little tricky to figure out what to do about subheadings. Do > >> they count as content or not? > >> > >> Richard Parsons writes: > >> > >> > Hi there > >> > > >> > Is there a function that will give me the content of the current > item? I > >> > mean simply the text of the whole item without its heading or > properties > >> > drawer. > >> > > >> > It seems to me likely that such a function would exist, but I haven't > >> been > >> > able to find it in the documentation. > >> > > >> > Many thanks > >> > Richard > >> > >> > >> -- > >> 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 > >> > > > -- > 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 > -- Richard Parsons Email: richard.lee.parsons@googlemail.com [-- Attachment #2: Type: text/html, Size: 4369 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-08 17:20 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-05-07 23:04 Function to return content of item Richard Parsons 2017-05-08 0:45 ` John Kitchin [not found] ` <CAB+=1LFbo7_nysB2TfcrDHZ87bjdMCEGAg5zu38nOi78qEbJ8g@mail.gmail.com> 2017-05-08 15:05 ` John Kitchin 2017-05-08 17:19 ` Richard Parsons
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).