[emacs-berlin] Magic magit

Rasmus rasmus at gmx.us
Sun Oct 4 20:47:07 UTC 2015


Tilmann Singer <tils at tils.net> writes:

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

To the best of my knowledge this is incorrect.  org-capture-templates
supports a function target cf. the docstring.

       (function function-finding-location)
          Most general way, write your own function to find both
          file and location

I haven’t used this, and you may have to Use The Source, to figure how the
functions is supposed to work.  Here’s an example of a file+function

("j" "article" item 
           (file+function "~/documents/papers.org"
                          (lambda ()
                              "File note to: "
                                (lambda (hl)
                                  (and (= (org-element-property :level hl) 1)
                                       (org-element-property :title hl)))))
                             nil nil)
                            (forward-line 1)
                            (insert "\n"))
            :prepend t
            :empty-lines-after 1)
           "%U: %?\n")

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

As you prefer; IMO it’s over-complicating.

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

I see the same.  Something funky is going on, though I’m not sure what.
Try to put it into a function and run it through edebug.  Then it works...

As you suggests, this probably has something to do with invisibility of
the link...  I don’t have a satisfactory answer to this.

>> (insert "\n") ? 
> Right, (org-return) is over the top. Maybe even (newline) ?

Yeah.  Org return is magic in headlines (TODOs and tags are preserved
since 8.3 I think) and tables.


I hear there's rumors on the, uh, Internets. . .

More information about the emacs-berlin mailing list