[emacs-berlin] Magic magit

Rasmus rasmus at gmx.us
Thu Oct 1 22:11:25 UTC 2015


Hi,

Tilmann Singer <tils at tils.net> writes:

>     (with-current-buffer (find-file-noselect org-file)
>       (save-excursion
>         (end-of-buffer)
>         (org-insert-heading nil nil t)
>         (org-todo "TODO")
>         (insert link)
>         (org-set-tags-to ":mail:")
>         ;; NOTE: tags should already be aligned, but they are not. This
>         ;; doesn't work either: (org-set-tags nil t)

-1. You should use org-capture.  It's designed for exactly this.  Except
    the "move from inbox to org" which I don't understand.

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

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

    For a complete example see e.g. org-remove-indentation (in org ≥ 8.3)

>         (org-set-tags nil t)
>         (org-return)

(insert "\n") ? 

> (defun notmuch-stuff--guess-org-file ()
>   "Guess which org file an email belongs to, fall back to projects"
>   (let (
>         (subject (or (notmuch-show-get-subject) ""))
>         (from (or (notmuch-show-get-from) ""))
>         (to (or (notmuch-show-get-to) ""))
>         (cc (or (notmuch-show-get-cc) "")))
>     (cond
>
>           ;; some conditions snipped
>
>           ((string-match-p "@emacs-berlin\\.org" to) "~/org/emacs.org")
>           ((string-match-p "@emacs-berlin\\.org" cc) "~/org/emacs.org")
>           ((string-match-p "\\[rubycorns\\]" subject) "~/org/railsgirls.org")
>           ((string-match-p "\\[rorganize\\.it\\]" subject) "~/org/railsgirls.org")
>           ((string-match-p "@railsgirlsberlin\\.de" to) "~/org/railsgirls.org")
>           ((string-match-p "@railsgirlsberlin\\.de" cc) "~/org/railsgirls.org")e
>           ((string-match-p "@railsgirlsberlin\\.de" from) "~/org/railsgirls.org")
>           (t "~/org/projects.org"))))
>

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

Hope it helps,
Rasmus

-- 
Hooray!



More information about the emacs-berlin mailing list