* Q : select current org item as region
@ 2010-09-08 18:51 Richard Riley
2010-09-08 19:40 ` Richard Riley
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Richard Riley @ 2010-09-08 18:51 UTC (permalink / raw)
To: emacs-orgmode
What would be the best elisp way to select the current org entry? I want
a hot key to select the current item as current region (not into the
clipboard).
The problem I am having is that org-in-item-p is returning nil even
though the point is in an org-item. Is the docstring where it mentions
"hand-formatted item" more significant that I understand? As a result
org-beginning-of-item is failing
Currently the function I have is (not working but to give you the idea
of what I am trying to accomplish):
(defun rgr/org-blog-entry ()
(interactive)
(save-excursion
(org-beginning-of-item)
(set-mark-command)
(org-end-of-item)
(let((tmpbuf (make-temp-file)))
(org-export-as-html nil nil tmpbuf t))))
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Q : select current org item as region
2010-09-08 18:51 Q : select current org item as region Richard Riley
@ 2010-09-08 19:40 ` Richard Riley
2010-09-08 21:06 ` Richard Riley
2010-09-08 19:51 ` Nicolas Goaziou
2010-09-09 12:48 ` Łukasz Stelmach
2 siblings, 1 reply; 11+ messages in thread
From: Richard Riley @ 2010-09-08 19:40 UTC (permalink / raw)
To: emacs-orgmode
Richard Riley <rileyrg@gmail.com> writes:
> What would be the best elisp way to select the current org entry? I want
> a hot key to select the current item as current region (not into the
> clipboard).
>
> The problem I am having is that org-in-item-p is returning nil even
> though the point is in an org-item. Is the docstring where it mentions
> "hand-formatted item" more significant that I understand? As a result
> org-beginning-of-item is failing
>
> Currently the function I have is (not working but to give you the idea
> of what I am trying to accomplish):
>
> (defun rgr/org-blog-entry ()
> (interactive)
> (save-excursion
> (org-beginning-of-item)
> (set-mark-command)
> (org-end-of-item)
> (let((tmpbuf (make-temp-file)))
> (org-export-as-html nil nil tmpbuf t))))
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
OK, minus several million for me for not digging deep enough. "item" is
not an org item per se but a list item. I need the entry functions. So
its taking shape (but not working yet ..) as
(defun rgr/org-blog-entry ()
(interactive)
(save-excursion
(goto-char (org-entry-beginning-position))
(set-mark (org-entry-end-position))
(let((tmpfile (make-temp-file "org-blog-html-")))
(org-export-as-html nil nil (find-file-noselect tmpfile) t))))
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Q : select current org item as region
2010-09-08 19:40 ` Richard Riley
@ 2010-09-08 21:06 ` Richard Riley
0 siblings, 0 replies; 11+ messages in thread
From: Richard Riley @ 2010-09-08 21:06 UTC (permalink / raw)
To: emacs-orgmode
I now have a working function to blog the current org-entry to google
blogs (blogger,blogspot) . See new thread "Blogging org entries using
google command line".
Richard Riley <rileyrg@gmail.com> writes:
> Richard Riley <rileyrg@gmail.com> writes:
>
>> What would be the best elisp way to select the current org entry? I want
>> a hot key to select the current item as current region (not into the
>> clipboard).
>>
>> The problem I am having is that org-in-item-p is returning nil even
>> though the point is in an org-item. Is the docstring where it mentions
>> "hand-formatted item" more significant that I understand? As a result
>> org-beginning-of-item is failing
>>
>> Currently the function I have is (not working but to give you the idea
>> of what I am trying to accomplish):
>>
>> (defun rgr/org-blog-entry ()
>> (interactive)
>> (save-excursion
>> (org-beginning-of-item)
>> (set-mark-command)
>> (org-end-of-item)
>> (let((tmpbuf (make-temp-file)))
>> (org-export-as-html nil nil tmpbuf t))))
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>>
>
> OK, minus several million for me for not digging deep enough. "item" is
> not an org item per se but a list item. I need the entry functions. So
> its taking shape (but not working yet ..) as
>
> (defun rgr/org-blog-entry ()
> (interactive)
> (save-excursion
> (goto-char (org-entry-beginning-position))
> (set-mark (org-entry-end-position))
> (let((tmpfile (make-temp-file "org-blog-html-")))
> (org-export-as-html nil nil (find-file-noselect tmpfile) t))))
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
--
☘ http://www.shamrockirishbar.com, http://www.richardriley.net
"Learning French is trivial: the word for horse is 'cheval' and
everything follows thusly."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Q : select current org item as region
2010-09-08 18:51 Q : select current org item as region Richard Riley
2010-09-08 19:40 ` Richard Riley
@ 2010-09-08 19:51 ` Nicolas Goaziou
2010-09-09 7:52 ` Bastien
2010-09-09 12:48 ` Łukasz Stelmach
2 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2010-09-08 19:51 UTC (permalink / raw)
To: Richard Riley; +Cc: emacs-orgmode
Hello,
>>>>> Richard Riley writes:
> What would be the best elisp way to select the current org entry? I
> want a hot key to select the current item as current region (not
> into the clipboard).
> The problem I am having is that org-in-item-p is returning nil even
> though the point is in an org-item. Is the docstring where it
> mentions "hand-formatted item" more significant that I understand?
> As a result org-beginning-of-item is failing
Could you elaborate on that? Could you give a minimal example? If
`org-in-item-p' is returning nil whereas you are in an item, there is
definitely a bug to fix.
Here is a suggestion to mark current item:
(defun mark-current-item ()
(interactive)
(when (org-in-item-p)
(goto-char (org-get-item-beginning))
(push-mark nil t t)
(goto-char (org-get-end-of-item (org-list-bottom-point)))))
Regards,
-- Nicolas
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Q : select current org item as region
2010-09-08 19:51 ` Nicolas Goaziou
@ 2010-09-09 7:52 ` Bastien
0 siblings, 0 replies; 11+ messages in thread
From: Bastien @ 2010-09-09 7:52 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode, Richard Riley
Nicolas Goaziou <n.goaziou@gmail.com> writes:
> (defun mark-current-item ()
> (interactive)
> (when (org-in-item-p)
> (goto-char (org-get-item-beginning))
> (push-mark nil t t)
> (goto-char (org-get-end-of-item (org-list-bottom-point)))))
Interesting -- looks like a good candidate for worg/org-hacks.org
Maybe with variants like
- narrowing to the item
- selecting it (depending on transient-mark-mode)
- cloning it
- killing it*
... just a thought.
* Would people would find it to have C-k to kill a whole item if a
certain option is set? I think I would. It's rare to have to kill
a line in a list item without having to kill the whole item.
--
Bastien
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Q : select current org item as region
2010-09-08 18:51 Q : select current org item as region Richard Riley
2010-09-08 19:40 ` Richard Riley
2010-09-08 19:51 ` Nicolas Goaziou
@ 2010-09-09 12:48 ` Łukasz Stelmach
2010-09-09 13:03 ` Richard Riley
2 siblings, 1 reply; 11+ messages in thread
From: Łukasz Stelmach @ 2010-09-09 12:48 UTC (permalink / raw)
To: emacs-orgmode
Richard Riley <rileyrg@gmail.com> writes:
> What would be the best elisp way to select the current org entry? I want
> a hot key to select the current item as current region (not into the
> clipboard).
>
This is mine:
--8<---------------cut here---------------start------------->8---
(defun stl/outline-mark-subtree ()
"Mark the current subtree in an outlined document.
This puts point at the start of the current subtree, and mark at the start
of the next."
(interactive)
(let ((beg))
(if (outline-on-heading-p)
;; we are already looking at a heading
(beginning-of-line)
;; else go back to previous heading
(outline-previous-visible-heading 1))
(setq beg (point))
(outline-end-of-subtree)
(outline-next-visible-heading 1) ; just before the next heading (stl)
(push-mark (point) nil t)
(goto-char beg)))
--8<---------------cut here---------------end--------------->8---
it's derived from the original outline-mark subtree but marks an empty
space before a next-same-level-heading.
--
Miłego dnia,
Łukasz Stelmach
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Q : select current org item as region
2010-09-09 12:48 ` Łukasz Stelmach
@ 2010-09-09 13:03 ` Richard Riley
2010-09-09 13:29 ` Nicolas Goaziou
2010-09-10 13:51 ` Łukasz Stelmach
0 siblings, 2 replies; 11+ messages in thread
From: Richard Riley @ 2010-09-09 13:03 UTC (permalink / raw)
To: emacs-orgmode
Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:
> Richard Riley <rileyrg@gmail.com> writes:
>
>> What would be the best elisp way to select the current org entry? I want
>> a hot key to select the current item as current region (not into the
>> clipboard).
>>
>
> This is mine:
>
>
>
> (defun stl/outline-mark-subtree ()
> "Mark the current subtree in an outlined document.
> This puts point at the start of the current subtree, and mark at the start
> of the next."
> (interactive)
> (let ((beg))
> (if (outline-on-heading-p)
> ;; we are already looking at a heading
> (beginning-of-line)
> ;; else go back to previous heading
> (outline-previous-visible-heading 1))
> (setq beg (point))
> (outline-end-of-subtree)
> (outline-next-visible-heading 1) ; just before the next heading (stl)
> (push-mark (point) nil t)
> (goto-char beg)))
>
>
>
> it's derived from the original outline-mark subtree but marks an empty
> space before a next-same-level-heading.
Thanks for the replies.
Just for google completeness
(goto-char (org-entry-beginning-position))
(set-mark (org-entry-end-position))
seemed the most efficient after digging about a bit.
regards
r.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Re: Q : select current org item as region
2010-09-09 13:03 ` Richard Riley
@ 2010-09-09 13:29 ` Nicolas Goaziou
2010-09-09 13:40 ` Richard Riley
2010-09-10 13:51 ` Łukasz Stelmach
1 sibling, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2010-09-09 13:29 UTC (permalink / raw)
To: Richard Riley; +Cc: emacs-orgmode
Hello,
>>>>> Richard Riley writes:
> Just for google completeness
> (goto-char (org-entry-beginning-position)) (set-mark
> (org-entry-end-position))
> seemed the most efficient after digging about a bit.
As a side note,
(goto-char (org-entry-beginning-position))
is in fact a convoluted way (if you don't need point value) of calling
(outline-back-to-heading t)
so I doubt this is the "most efficient" in this case.
Regards,
-- Nicolas
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Q : select current org item as region
2010-09-09 13:29 ` Nicolas Goaziou
@ 2010-09-09 13:40 ` Richard Riley
0 siblings, 0 replies; 11+ messages in thread
From: Richard Riley @ 2010-09-09 13:40 UTC (permalink / raw)
To: emacs-orgmode
Nicolas Goaziou <n.goaziou@gmail.com> writes:
> Hello,
>>>>>> Richard Riley writes:
>
>> Just for google completeness
>
>> (goto-char (org-entry-beginning-position)) (set-mark
>> (org-entry-end-position))
>
>> seemed the most efficient after digging about a bit.
>
> As a side note,
>
> (goto-char (org-entry-beginning-position))
>
> is in fact a convoluted way (if you don't need point value) of calling
>
> (outline-back-to-heading t)
>
> so I doubt this is the "most efficient" in this case.
>
Good spot - but I will probably stick to the org- functions in general
in case they are ever expanded for whatever reasons.
The speed overhead in an interactive environment is pretty much zero ;)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Q : select current org item as region
2010-09-09 13:03 ` Richard Riley
2010-09-09 13:29 ` Nicolas Goaziou
@ 2010-09-10 13:51 ` Łukasz Stelmach
2010-09-10 14:45 ` Richard Riley
1 sibling, 1 reply; 11+ messages in thread
From: Łukasz Stelmach @ 2010-09-10 13:51 UTC (permalink / raw)
To: emacs-orgmode
Richard Riley <rileyrg@gmail.com> writes:
> Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:
>> Richard Riley <rileyrg@gmail.com> writes:
>>> What would be the best elisp way to select the current org entry? I want
>>> a hot key to select the current item as current region (not into the
>>> clipboard).
>>>
>> This is mine:
>>
>> (defun stl/outline-mark-subtree ()
[...]
>>
>> it's derived from the original outline-mark subtree but marks an empty
>> space before a next-same-level-heading.
>
> Thanks for the replies.
>
> Just for google completeness
>
> (goto-char (org-entry-beginning-position))
> (set-mark (org-entry-end-position))
>
> seemed the most efficient after digging about a bit.
It's not the same, it does not include the subtree. Take for example:
--8<---------------cut here---------------start------------->8---
* Top 1
Some text in the Top 1 node
** Bottom 1
Some more text.
** Bottom 2
No text at all
* Top 2
Another toplevel entry.
--8<---------------cut here---------------end--------------->8---
If you place point on the second line of the above example,
(stl/)?outline-mark function will mark: Top 1, Bottom 1 and Bottom 2,
nodes with their content. While the org-entry-(beginning|end)-position
will provide you only with Top 1 heading and a text before Bottom 1.
--
Miłego dnia,
Łukasz Stelmach
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Q : select current org item as region
2010-09-10 13:51 ` Łukasz Stelmach
@ 2010-09-10 14:45 ` Richard Riley
0 siblings, 0 replies; 11+ messages in thread
From: Richard Riley @ 2010-09-10 14:45 UTC (permalink / raw)
To: emacs-orgmode
Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:
> Richard Riley <rileyrg@gmail.com> writes:
>
>> Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:
>>> Richard Riley <rileyrg@gmail.com> writes:
>>>> What would be the best elisp way to select the current org entry? I want
>>>> a hot key to select the current item as current region (not into the
>>>> clipboard).
>>>>
>>> This is mine:
>>>
>>> (defun stl/outline-mark-subtree ()
> [...]
>>>
>>> it's derived from the original outline-mark subtree but marks an empty
>>> space before a next-same-level-heading.
>>
>> Thanks for the replies.
>>
>> Just for google completeness
>>
>> (goto-char (org-entry-beginning-position))
>> (set-mark (org-entry-end-position))
>>
>> seemed the most efficient after digging about a bit.
>
> It's not the same, it does not include the subtree. Take for example:
>
>
>
> * Top 1
> Some text in the Top 1 node
> ** Bottom 1
> Some more text.
> ** Bottom 2
> No text at all
> * Top 2
> Another toplevel entry.
>
>
>
> If you place point on the second line of the above example,
> (stl/)?outline-mark function will mark: Top 1, Bottom 1 and Bottom 2,
> nodes with their content. While the org-entry-(beginning|end)-position
> will provide you only with Top 1 heading and a text before Bottom 1.
Hi Lukasz,
You are right and sub trees should be included. I was just looking at that
while refitting the core blog part to be called more generally.
I used :
(org-forward-same-level 1 t)
to do the same.
http://github.com/rileyrg/org-googlecl/blob/subtrees-0.01/org-googlecl.el
Seems to be working ok now.
regards
r.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2010-09-10 14:46 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-08 18:51 Q : select current org item as region Richard Riley
2010-09-08 19:40 ` Richard Riley
2010-09-08 21:06 ` Richard Riley
2010-09-08 19:51 ` Nicolas Goaziou
2010-09-09 7:52 ` Bastien
2010-09-09 12:48 ` Łukasz Stelmach
2010-09-09 13:03 ` Richard Riley
2010-09-09 13:29 ` Nicolas Goaziou
2010-09-09 13:40 ` Richard Riley
2010-09-10 13:51 ` Łukasz Stelmach
2010-09-10 14:45 ` Richard Riley
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).