[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Scatter-gather idea

From: John Kitchin
Subject: Re: [O] Scatter-gather idea
Date: Thu, 06 Apr 2017 15:40:40 -0400
User-agent: mu4e 0.9.19; emacs 25.1.1

I am sympathetic to not wanting to use tags here. It would be tedious to
tag them all, and then remove them (my opinion of course;). Here is some
code that you can "mark" headlines with a speed command (M on a headline
start) or interactively. This just stores a marker to the headline in a
global variable. Then, use M-x scatter-gather to put them all into one
temporary buffer. From there you can manipulate them any way you want,
and save the result anyway you want. You could modify scatter-gather to
either copy or move the headlines.

You could also use overlays to indicate a headline had been marked, and
make some convenience functions to remove headlines from the list, but I
leave those for exercises ;)

This code is lightly tested.

#+BEGIN_SRC emacs-lisp
(defvar scatter-gather-markers '()
  "List of markers where headlines are for gathering.")

(defun scatter-gather-mark-heading ()
  "Add the current headline to `scatter-gather-markers'."
  (unless (org-at-heading-p)
  (add-to-list 'scatter-gather-markers (point-marker)))

(defun scatter-gather ()
  "Gather marked headlines into a temporary buffer"
  (when scatter-gather-markers
    (switch-to-buffer-other-window (get-buffer-create "*scatter-gather*"))
    (loop for marker in (reverse scatter-gather-markers)
          (insert (with-current-buffer (marker-buffer marker)
                      (goto-char (marker-position marker))
                      (buffer-substring (point) (mark))))))
    (setq scatter-gather-markers '())))

(add-to-list 'org-speed-commands-user (cons "M" 'scatter-gather-mark-heading))

Nick Dokos writes:

> Bob Newell <address@hidden> writes:
>>>> mark them with tags, and do org-tags-view. Or, you can use regex or other
>>>> criteria if you like.
>>> That was my first thought too: I didn't think any extra functionality is 
>>> needed.
>> I looked into this earlier but agenda bulk marking doesn't seem to work
>> in an arbitrary org-mode buffer; it must be an agenda buffer, and you
>> can only mark certain entries.
>> The tag idea may be the best way. Thanks to all for the replies.
> Yes, sorry: I was talking about tags, not about agenda bulk-marking. Although 
> you
> can add an arbitrary org file to the agend with `C-c [', do what you need to 
> do,
> and then remove it with `C-c ]'.

Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213

reply via email to

[Prev in Thread] Current Thread [Next in Thread]