[Orgmode] Re: Q : select current org item as region

2010-09-10 Thread Richard Riley
Łukasz Stelmach  writes:

> Richard Riley  writes:
>
>> Łukasz Stelmach  writes:
>>> 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).

>>> 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.


___
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


[Orgmode] Re: Q : select current org item as region

2010-09-10 Thread Łukasz Stelmach
Richard Riley  writes:

> Łukasz Stelmach  writes:
>> 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).
>>>
>> 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


___
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


[Orgmode] Re: Q : select current org item as region

2010-09-09 Thread Richard Riley
Nicolas Goaziou  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 ;) 



___
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


Re: [Orgmode] Re: Q : select current org item as region

2010-09-09 Thread Nicolas Goaziou
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

___
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


[Orgmode] Re: Q : select current org item as region

2010-09-09 Thread Richard Riley
Łukasz Stelmach  writes:

> 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).
>>
>
> 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.


___
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


[Orgmode] Re: Q : select current org item as region

2010-09-09 Thread Łukasz Stelmach
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).
>

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


___
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


[Orgmode] Re: Q : select current org item as region

2010-09-08 Thread Richard Riley


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  writes:

> 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
>>
>> 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."


___
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


[Orgmode] Re: Q : select current org item as region

2010-09-08 Thread Richard Riley
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
>
> 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