* Help with elisp function
@ 2012-01-13 0:32 Marcelo de Moraes Serpa
2012-01-13 8:45 ` Olaf Dietsche
0 siblings, 1 reply; 3+ messages in thread
From: Marcelo de Moraes Serpa @ 2012-01-13 0:32 UTC (permalink / raw)
To: Org Mode
[-- Attachment #1: Type: text/plain, Size: 1385 bytes --]
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.
Any hints appreciated!
Marcelo.
[-- Attachment #2: Type: text/html, Size: 1941 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Help with elisp function
2012-01-13 0:32 Help with elisp function Marcelo de Moraes Serpa
@ 2012-01-13 8:45 ` Olaf Dietsche
2012-01-14 19:28 ` Marcelo de Moraes Serpa
0 siblings, 1 reply; 3+ messages in thread
From: Olaf Dietsche @ 2012-01-13 8:45 UTC (permalink / raw)
To: Marcelo de Moraes Serpa; +Cc: Org Mode
Marcelo de Moraes Serpa <celoserpa@gmail.com> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Help with elisp function
2012-01-13 8:45 ` Olaf Dietsche
@ 2012-01-14 19:28 ` Marcelo de Moraes Serpa
0 siblings, 0 replies; 3+ messages in thread
From: Marcelo de Moraes Serpa @ 2012-01-14 19:28 UTC (permalink / raw)
To: Olaf Dietsche; +Cc: Org Mode
[-- Attachment #1: Type: text/plain, Size: 2289 bytes --]
Thanks Olaf, I will check it out and let you know how it goes :)
On Fri, Jan 13, 2012 at 2:45 AM, Olaf Dietsche <
olaf+list.orgmode@olafdietsche.de> wrote:
> Marcelo de Moraes Serpa <celoserpa@gmail.com> 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
>
[-- Attachment #2: Type: text/html, Size: 3120 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-01-14 19:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-13 0:32 Help with elisp function Marcelo de Moraes Serpa
2012-01-13 8:45 ` Olaf Dietsche
2012-01-14 19:28 ` Marcelo de Moraes Serpa
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).