Hello,
Just curious of there's a way to set the tags in a region all at once?
I see there's a way to do it via agenda, but I was curious if there
was also a way to do it on a group of headlines from the buffer
itself. In various google strategies, it looked like the answer was
no.
This is just a random file (making a camping packing/shopping list),
so to do it via the way that seemed apparent was:
C-c a
> to restrict to the file
s to conduct a "fake search" that would just give all the headlines in
the buffer
highlight region
: to set tags
It would have just been easier to C-space on a region and set them in
groups right from the buffer. I sort of expected something like C-u
C-c C-c to set region tags? Thinking about it, I suppose since these
happened to be tagged with :export:, I could have done an M-x
replace-string and appended my additional tag.
Thanks!
John
John Hendy <jw.hendy@gmail.com> writes: > Hello, > > > Just curious of there's a way to set the tags in a region all at once? (org-map-entries (function org-set-tags) nil 'region) or (org-map-entries (lambda () (org-set-tags-to '(foo))) nil 'region) or some variation thereof. > I see there's a way to do it via agenda, but I was curious if there > was also a way to do it on a group of headlines from the buffer > itself. In various google strategies, it looked like the answer was > no. > > This is just a random file (making a camping packing/shopping list), > so to do it via the way that seemed apparent was: > > C-c a >> to restrict to the file > s to conduct a "fake search" that would just give all the headlines in > the buffer > highlight region > : to set tags > > It would have just been easier to C-space on a region and set them in > groups right from the buffer. I sort of expected something like C-u > C-c C-c to set region tags? Thinking about it, I suppose since these > happened to be tagged with :export:, I could have done an M-x > replace-string and appended my additional tag. > > > Thanks! > John > > -- Nick
Hello John,
On 2014-05-10 04:53 John Hendy wrote:
> Just curious of there's a way to set the tags in a region all at once?
> I see there's a way to do it via agenda, but I was curious if there
> was also a way to do it on a group of headlines from the buffer
> itself. In various google strategies, it looked like the answer was
> no.
>
> This is just a random file (making a camping packing/shopping list),
> so to do it via the way that seemed apparent was:
I often use (info "(Emacs) Keyboard Macros") for situations like
this. Define the macro with point at the beginning of a headline and
then use `C-x C-k r' to execute it on every line in a region.
[The (info ...) form above when evaluated takes you to the relevant page
in the emacs manual.]
HTH,
--
Alexander Baier
Hello John,
On 2014-05-10 04:53 John Hendy wrote:
> Just curious of there's a way to set the tags in a region all at once?
You could also takle this with keyboard macros, see
(info "(Emacs) Keyboard Macros"). [Evaluate that expression in emacs to
see the relevant manual entry.]
Define a macro that tags one specific headline and then execute it on
the current region with `C-x C-k r'.
HTH,
--
Alexander Baier
[-- Attachment #1: Type: text/plain, Size: 1504 bytes --] On May 9, 2014 11:21 PM, "Nick Dokos" <ndokos@gmail.com> wrote: > > John Hendy <jw.hendy@gmail.com> writes: > > > Hello, > > > > > > Just curious of there's a way to set the tags in a region all at once? > > (org-map-entries (function org-set-tags) nil 'region) > > or > > (org-map-entries (lambda () (org-set-tags-to '(foo))) nil 'region) > > or some variation thereof. > I did see that function, but it didn't DUI what I expected with M-x. Would u need to run it as above or could I use M-x with it somehow? A above I take it I'd put that in the buffer and then eval-region? John > > I see there's a way to do it via agenda, but I was curious if there > > was also a way to do it on a group of headlines from the buffer > > itself. In various google strategies, it looked like the answer was > > no. > > > > This is just a random file (making a camping packing/shopping list), > > so to do it via the way that seemed apparent was: > > > > C-c a > >> to restrict to the file > > s to conduct a "fake search" that would just give all the headlines in > > the buffer > > highlight region > > : to set tags > > > > It would have just been easier to C-space on a region and set them in > > groups right from the buffer. I sort of expected something like C-u > > C-c C-c to set region tags? Thinking about it, I suppose since these > > happened to be tagged with :export:, I could have done an M-x > > replace-string and appended my additional tag. > > > > > > Thanks! > > John > > > > > > -- > Nick > > [-- Attachment #2: Type: text/html, Size: 2155 bytes --]
On 2014-05-10 16:14 John Hendy wrote:
> On May 9, 2014 11:21 PM, "Nick Dokos" <ndokos@gmail.com> wrote:
>>
>> John Hendy <jw.hendy@gmail.com> writes:
>>
>> > Hello,
>> >
>> >
>> > Just curious of there's a way to set the tags in a region all at once?
>>
>> (org-map-entries (function org-set-tags) nil 'region)
>>
>> or
>>
>> (org-map-entries (lambda () (org-set-tags-to '(foo))) nil 'region)
>>
>> or some variation thereof.
>>
>
> I did see that function, but it didn't DUI what I expected with M-x. Would
> u need to run it as above or could I use M-x with it somehow?
>
> A above I take it I'd put that in the buffer and then eval-region?
If you want to call this interactively, i.e. via M-x or a key-binding,
you will have to wrap this code in a defun with an interactive
from and thus turn it into a command. Like this:
#+BEGIN_SRC emacs-lisp
(defun my-set-tag-in-region ()
(interactive)
(org-map-entries (function org-set-tags) nil 'region))
#+END_SRC
HTH,
--
Alexander Baier
As I don't see it mentioned in this thread: (setq org-loop-over-headlines-in-active-region t) will do wonders for several commands. If someone has a good idea where to put this in the manual, I'm all ears! -- Bastien