emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Help with elisp function


From: Olaf Dietsche
Subject: Re: [O] Help with elisp function
Date: Fri, 13 Jan 2012 09:45:10 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Marcelo de Moraes Serpa <address@hidden> writes:

> So, I made a small elisp function that basically creates a "reference
> file" in my org dir and indexes it in an org file, so it can be
> searchable with the agenda without the overhead of adding the file to
> the agenda list:
>
> (defun create-reference-file (filename title tags) "Creates a new
> reference and file it"
>   (interactive (list
>                 (read-string "Filename: ") (read-string "Title: ")
>                 (read-string "Tags: ") ))
>   (set-buffer (get-buffer-create filename)) (beginning-of-buffer)
>   (insert (concat "* tags " tags))
>    ;;saves the buffer (when (file-writable-p filename)
>       (write-region (point-min) (point-max) (concat
> "~/org/data/dynamic_reference/" filename ".org")))
>   (set-buffer (find-file-noselect "~/org/gtd/reference.org"))
>   (end-of-buffer) ;;(create-wiki-page filename) (insert (concat "** "
>   title " " tags ":reference:file:\n")) (org-insert-time-stamp nil t
>   nil) (insert "\n") (insert (concat
>   "[[file://~/org/data/dynamic_reference/" filename
> ".org]]"))
>   (insert "\n") (save-buffer) )
>
> I'm only beginning with elisp, so bear with me...
>
> Anyway, it works as expected, but I would like the tags prompt to be
> like the prompt org uses, with tags auto-completion and adding the : :
> automatically around the tags. Right now, I have to type the : around
> the words.

C-h c C-c C-q runs the command org-set-tags-command.
org-set-tags-command calls org-set-tags. Looking through org-set-tags in
org.el, there's a part starting with a comment:

        ;; Get a new set of tags from the user
        ...
                  (let ((org-add-colon-after-tag-completion t))
                    (org-trim
                     (org-icompleting-read "Tags: "
                                           'org-tags-completion-function
                                           nil nil current 
'org-tags-history))))))
        ...

So, I guess org-icompleting-read is, what you are looking for.

Regards, Olaf



reply via email to

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