From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olaf Dietsche Subject: Re: Help with elisp function Date: Fri, 13 Jan 2012 09:45:10 +0100 Message-ID: <87pqeoc7op.fsf@rat.lan> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([140.186.70.92]:41355) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlclF-0002Ze-5Y for emacs-orgmode@gnu.org; Fri, 13 Jan 2012 03:45:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlclD-0007gZ-MV for emacs-orgmode@gnu.org; Fri, 13 Jan 2012 03:45:21 -0500 Received: from www85.your-server.de ([213.133.104.85]:37738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlclD-0007fx-Hu for emacs-orgmode@gnu.org; Fri, 13 Jan 2012 03:45:19 -0500 In-Reply-To: (Marcelo de Moraes Serpa's message of "Thu, 12 Jan 2012 18:32:20 -0600") 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: Marcelo de Moraes Serpa Cc: Org Mode 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