emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Set tags in region
@ 2014-05-10  2:53 John Hendy
  2014-05-10  4:20 ` Nick Dokos
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: John Hendy @ 2014-05-10  2:53 UTC (permalink / raw)
  To: emacs-orgmode

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

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

* Re: Set tags in region
  2014-05-10  2:53 Set tags in region John Hendy
@ 2014-05-10  4:20 ` Nick Dokos
  2014-05-10 14:14   ` John Hendy
  2014-05-10  9:08 ` Alexander Baier
  2014-05-10 11:00 ` Alexander Baier
  2 siblings, 1 reply; 7+ messages in thread
From: Nick Dokos @ 2014-05-10  4:20 UTC (permalink / raw)
  To: emacs-orgmode

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

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

* Re: Set tags in region
  2014-05-10  2:53 Set tags in region John Hendy
  2014-05-10  4:20 ` Nick Dokos
@ 2014-05-10  9:08 ` Alexander Baier
  2014-05-21  2:29   ` Bastien
  2014-05-10 11:00 ` Alexander Baier
  2 siblings, 1 reply; 7+ messages in thread
From: Alexander Baier @ 2014-05-10  9:08 UTC (permalink / raw)
  To: John Hendy; +Cc: emacs-orgmode

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

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

* Re: Set tags in region
  2014-05-10  2:53 Set tags in region John Hendy
  2014-05-10  4:20 ` Nick Dokos
  2014-05-10  9:08 ` Alexander Baier
@ 2014-05-10 11:00 ` Alexander Baier
  2 siblings, 0 replies; 7+ messages in thread
From: Alexander Baier @ 2014-05-10 11:00 UTC (permalink / raw)
  To: emacs-orgmode

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

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

* Re: Set tags in region
  2014-05-10  4:20 ` Nick Dokos
@ 2014-05-10 14:14   ` John Hendy
  2014-05-10 16:55     ` Alexander Baier
  0 siblings, 1 reply; 7+ messages in thread
From: John Hendy @ 2014-05-10 14:14 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

[-- 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 --]

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

* Re: Set tags in region
  2014-05-10 14:14   ` John Hendy
@ 2014-05-10 16:55     ` Alexander Baier
  0 siblings, 0 replies; 7+ messages in thread
From: Alexander Baier @ 2014-05-10 16:55 UTC (permalink / raw)
  To: John Hendy; +Cc: Nick Dokos, emacs-orgmode

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

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

* Re: Set tags in region
  2014-05-10  9:08 ` Alexander Baier
@ 2014-05-21  2:29   ` Bastien
  0 siblings, 0 replies; 7+ messages in thread
From: Bastien @ 2014-05-21  2:29 UTC (permalink / raw)
  To: Alexander Baier; +Cc: emacs-orgmode

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

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

end of thread, other threads:[~2014-05-21  2:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-10  2:53 Set tags in region John Hendy
2014-05-10  4:20 ` Nick Dokos
2014-05-10 14:14   ` John Hendy
2014-05-10 16:55     ` Alexander Baier
2014-05-10  9:08 ` Alexander Baier
2014-05-21  2:29   ` Bastien
2014-05-10 11:00 ` Alexander Baier

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