[emacs-berlin] Magic magit

Tilmann Singer tils at tils.net
Thu Oct 1 23:21:16 UTC 2015


Hi Rasmus,

Rasmus <rasmus at gmx.us> writes:
> -1. You should use org-capture.  It's designed for exactly this.  Except
>     the "move from inbox to org" which I don't understand.

Yes, I suppose I should have looked into org-capture more thoroughly
before. One thing that I don't see how it would be possible with
org-capture is to have a function pre-guess what would be the best
target file and suggest that, so that I only have to press enter to
accept the guess in most cases, but still have the possibility to change
it.

If I understand correctly, the org-capture approach would be either to
create a capture template for each possible target org file - with that
there would be no pre-guessing - or create a single capture template
that uses a custom function to select the target file. With this, it
wouldn't be possible to change the suggested guess though. Maybe this is
not a big deal anyway and I should just use that approach, I'll think
about it.

>  0. What's wrong with (insert "* TODO " link " :mail:") ?  You could get
>     the relative level with (org-outline-level).

Nothing wrong with insert, I just thought it would be good practice to
use org specific functions when doing things inside org-mode.

>  1. Tags are non-trivial.  First, if the tag column is set, it should be
>     respected (depending on org-auto-align-tags, of course).  If you care,
>     you check this with org-complex-heading-regexp.  For your script this
>     is probably sufficient,
>
>         (when org-auto-align-tags (org-align-tags-here org-tags-column))

this also doesn't indent it properly. It seems to be related to
inserting a link - with normal text inserted it works. This reproduces
it:

(with-current-buffer (find-file-noselect "/tmp/test.org")
  (save-excursion
    (end-of-buffer)
    (insert "* TODO " "[[file:~/.emacs.d/notmuch-stuff.el][This is a test]]")
    (org-set-tags-to ":mail:")
    (when org-auto-align-tags (org-align-tags-here org-tags-column))))

>     For a complete example see e.g. org-remove-indentation (in org ≥ 8.3)
>
>>         (org-set-tags nil t)
>>         (org-return)
>
> (insert "\n") ? 

Right, (org-return) is over the top. Maybe even (newline) ?

> I haven't tested this since I don't have notmuch (and lazy), but if you
> like `cl-lib' maybe you can extend on this:
>
>     (let ((subject (notmuch-show-get-subject))
>           (from (notmuch-show-get-from))
>           (to (notmuch-show-get-to))
>           (cc (notmuch-show-get-cc))
>           ;; Should be a defcustom...
>           (types '(("@emacs-berlin\\.org" "~/org/emacs.org" to cc)
>                    ("@railsgirlsberlin\\.de" "~/org/railsgirls.org" to cc from))))
>
>       (cl-some (lambda (entry) (cl-some (lambda (field)
>                                      (if (string-match-p (car entry) field)
>                                          (cadr entry))
>                                      (cl-remove-if-not 'identity (cddr entry)))))
>                types))

I'll try to wrap my head around it later.

Thanks for the input!


Til
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://mailb.org/pipermail/emacs-berlin/attachments/20151002/7d97d389/attachment.sig>


More information about the emacs-berlin mailing list