emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Nick Dokos <ndokos@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Scatter-gather idea
Date: Thu, 06 Apr 2017 15:40:40 -0400	[thread overview]
Message-ID: <m237dlz5mv.fsf@andrew.cmu.edu> (raw)
In-Reply-To: <87a87tqr87.fsf@alphaville.usersys.redhat.com>

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'."
  (interactive)
  (unless (org-at-heading-p)
    (outline-previous-heading))
  (add-to-list 'scatter-gather-markers (point-marker)))


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

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


Nick Dokos writes:

> Bob Newell <bobnewell@bobnewell.net> 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
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

  reply	other threads:[~2017-04-06 19:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-01 15:22 Bug: Can't execute C code block from remote directory [9.0.5 (release_9.0.5-401-g86ff11 @ /Users/xcy/src/org-mode/lisp/)] Chunyang Xu
2017-04-01 17:27 ` Scatter-gather idea Bob Newell
2017-04-01 18:41   ` John Kitchin
2017-04-01 20:12     ` Bob Newell
2017-04-03  2:48       ` Samuel Wales
2017-04-03  4:34         ` Bob Newell
2017-04-05  5:06           ` Yasushi SHOJI
2017-04-05 15:22             ` Nick Dokos
2017-04-06 18:28               ` Bob Newell
2017-04-06 19:19                 ` Nick Dokos
2017-04-06 19:40                   ` John Kitchin [this message]
2017-04-10  8:46           ` Daniel Clemente
2017-04-01 18:47   ` Bingo
2017-04-03  6:58 ` Bug: Can't execute C code block from remote directory [9.0.5 (release_9.0.5-401-g86ff11 @ /Users/xcy/src/org-mode/lisp/)] Chunyang Xu
2017-04-05  8:11   ` Nicolas Goaziou
2017-04-05 11:49     ` Chunyang Xu
2017-04-07 16:15       ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m237dlz5mv.fsf@andrew.cmu.edu \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=ndokos@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).