From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo de Moraes Serpa Subject: Re: Help with elisp function Date: Sat, 14 Jan 2012 13:28:16 -0600 Message-ID: References: <87pqeoc7op.fsf@rat.lan> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0015175cd80ab424fc04b681fbd0 Return-path: Received: from eggs.gnu.org ([140.186.70.92]:58238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm9HC-0001qQ-G7 for emacs-orgmode@gnu.org; Sat, 14 Jan 2012 14:28:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rm9H1-00061w-Pa for emacs-orgmode@gnu.org; Sat, 14 Jan 2012 14:28:30 -0500 Received: from mail-bk0-f41.google.com ([209.85.214.41]:65200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm9H1-00061U-7O for emacs-orgmode@gnu.org; Sat, 14 Jan 2012 14:28:19 -0500 Received: by bkuw5 with SMTP id w5so3774015bku.0 for ; Sat, 14 Jan 2012 11:28:17 -0800 (PST) In-Reply-To: <87pqeoc7op.fsf@rat.lan> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Olaf Dietsche Cc: Org Mode --0015175cd80ab424fc04b681fbd0 Content-Type: text/plain; charset=ISO-8859-1 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 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 > --0015175cd80ab424fc04b681fbd0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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&= gt; writes:

> So, I made a small elisp function that basically creates a "refer= ence
> 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<= br> > the agenda list:
>
> (defun create-reference-file (filename title tags) "Creates a new=
> reference and file it"
> =A0 (interactive (list
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (read-string "Filename: ") (= read-string "Title: ")
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (read-string "Tags: ") )) > =A0 (set-buffer (get-buffer-create filename)) (beginning-of-buffer) > =A0 (insert (concat "* tags " tags))
> =A0 =A0;;saves the buffer (when (file-writable-p filename)
> =A0 =A0 =A0 (write-region (point-min) (point-max) (concat
> "~/org/data/dynamic_reference/" filename ".org")))=
> =A0 (set-buffer (find-file-noselect "~/org/gtd/reference.org"))
> =A0 (end-of-buffer) ;;(create-wiki-page filename) (insert (concat &quo= t;** "
> =A0 title " " tags ":reference:file:\n")) (org-ins= ert-time-stamp nil t
> =A0 nil) (insert "\n") (insert (concat
> =A0 "[[file://~/org/data/dynamic_reference/" filename
> ".org]]"))
> =A0 (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<= br> > 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:

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

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

Regards, Olaf

--0015175cd80ab424fc04b681fbd0--