From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Use date in Easy Templates? Date: Sun, 16 Feb 2014 13:08:47 -0500 Message-ID: <87eh33exqo.fsf@gmail.com> References: <5300F3D8.6040104@krugs.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:60928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WF69O-0003uJ-2J for emacs-orgmode@gnu.org; Sun, 16 Feb 2014 13:09:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WF69H-0006O0-Rv for emacs-orgmode@gnu.org; Sun, 16 Feb 2014 13:09:10 -0500 Received: from plane.gmane.org ([80.91.229.3]:51582) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WF69H-0006Nu-LT for emacs-orgmode@gnu.org; Sun, 16 Feb 2014 13:09:03 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WF69E-0003og-PI for emacs-orgmode@gnu.org; Sun, 16 Feb 2014 19:09:00 +0100 Received: from pool-98-110-172-167.bstnma.fios.verizon.net ([98.110.172.167]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 16 Feb 2014 19:09:00 +0100 Received: from ndokos by pool-98-110-172-167.bstnma.fios.verizon.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 16 Feb 2014 19:09:00 +0100 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: emacs-orgmode@gnu.org Rainer M Krug writes: > is it possible to insert the actual date into Easy Templates? > No - but it's not difficult to crib the %file code and add %date: --8<---------------cut here---------------start------------->8--- (defun org-complete-expand-structure-template (start cell) "Expand a structure template." (let* ((musep (org-bound-and-true-p org-mtags-prefer-muse-templates)) (rpl (nth (if musep 2 1) cell)) (ind "")) (delete-region start (point)) (when (string-match "\\`#\\+" rpl) (cond ((bolp)) ((not (string-match "\\S-" (buffer-substring (point-at-bol) (point)))) (setq ind (buffer-substring (point-at-bol) (point)))) (t (newline)))) (setq start (point)) (if (string-match "%file" rpl) (setq rpl (replace-match (concat "\"" (save-match-data (abbreviate-file-name (read-file-name "Include file: "))) "\"") t t rpl))) ;;; ADDED CODE (if (string-match "%date" rpl) (setq rpl (replace-match (save-match-data (format-time-string "%Y-%m-%d" (current-time))) t t rpl))) ;;; END OF ADDED CODE (setq rpl (mapconcat 'identity (split-string rpl "\n") (concat "\n" ind))) (insert rpl) (if (re-search-backward "\\?" start t) (delete-char 1)))) --8<---------------cut here---------------end--------------->8--- However, the next thing somebody will ask is a different format for the date which will require YACV[fn:1]. But maybe one exists already? And the next thing is more of these %thingies... so it would be better to add yet another layer to the function, so that arbitrary %thingies can be added by customizing YACV, probably an alist of ("thingie" . thingie-function) pairs... Footnotes: [fn:1] Yet Another Customization Variable :-) -- Nick