From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: function for inserting a block Date: Thu, 09 Nov 2017 15:46:09 +0100 Message-ID: <87y3nfse6m.fsf@gmx.us> References: <877exghblx.fsf@ericabrahamsen.net> <87fuaiz069.fsf@nicolasgoaziou.fr> <87lgk9eo4d.fsf@ericabrahamsen.net> <87fuahxxvs.fsf@nicolasgoaziou.fr> <87r2u1cuwj.fsf@ericabrahamsen.net> <87infdctzq.fsf@ericabrahamsen.net> <87k1zsbizs.fsf@ericabrahamsen.net> <87k1zp4rxj.fsf@ericabrahamsen.net> <871slx4j6p.fsf@ericabrahamsen.net> <87376btslq.fsf@nicolasgoaziou.fr> <87vaj7oyxb.fsf@ericabrahamsen.net> <871sl9ow44.fsf@gnu.org> <87fu9pgfkj.fsf@nicolasgoaziou.fr> <87375ouanr.fsf@gmx.us> <871sl8e76c.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCo66-0000Ll-28 for emacs-orgmode@gnu.org; Thu, 09 Nov 2017 09:46:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCo62-0004wM-19 for emacs-orgmode@gnu.org; Thu, 09 Nov 2017 09:46:26 -0500 Received: from [195.159.176.226] (port=42183 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eCo61-0004uw-Q5 for emacs-orgmode@gnu.org; Thu, 09 Nov 2017 09:46:21 -0500 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eCo5p-0000bs-W4 for emacs-orgmode@gnu.org; Thu, 09 Nov 2017 15:46:09 +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" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Nicolas Goaziou writes: > Takaaki Ishikawa writes: > >> I also support the idea of keeping "> Please give importance to the backward compatibility in this case. > > I explained why I thought it could be removed. I also suggested > solutions to get an equivalent feature without implementing it in Org. Which sounds fair. > What is wrong with Abbrev mode, skeletons, tempo.el, expand.el, all > bundled with Emacs, or YASnippet, in the Emacs ecosystem? It sounds like > NIH. Or, to put it differently: why in the world would Org implement its > own template system? tempo.el, which I was unaware of, will be able to do this. Thanks for the pointer. I have started to write a replacement. It seems to work fairly OK so far. Not all keywords have been added, and no mechanism for adding additional keywords is there yet. Nicolas, what would be the best way to hook ‘tempo-complete-tag’ into "space"? Should I add support directly in org-self-insert-command or add it to post-command-hook? > The onbly argument so far is "<" cannot be expanded since it not word > constituent. Seriously. "<" has no meaning anyway. You can use "@", > which is word constituent and just as meaningless. So, you can define, > e.g., a skeleton, that will expand "@s" to "#+begin_src\n#+end_src". A small aside: on my keyboard layout < is easy to type. I don’t like typing @. > We can even document how to do it in the manual. Of course. Thanks, Rasmus -- I feel emotional landscapes they puzzle me --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=org-tempo.el Content-Transfer-Encoding: quoted-printable ;;; org.el --- Outline-based notes management and organizer -*- lexical-bin= ding: t; -*- ;; Carstens outline-mode for keeping track of everything. ;; Copyright (C) 2017 Free Software Foundation, Inc. ;; ;; Author: Rasmus Pank Roulund ;; Keywords: outlines, hypermedia, calendar, wp ;; Homepage: http://orgmode.org ;; ;; This file is part of GNU Emacs. ;; ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . ;; ;;; Commentary: ;; ;;; Code: (require 'org) (require 'tempo) (defvar org-tempo-tags nil "Tempo tags for org-mode") (defun org-tempo-setup () (tempo-use-tag-list 'org-tempo-tags) (setq-local tempo-match-finder "^ *\\(<[[:word:]]\\)\\=3D")) (add-hook 'org-mode-hook 'org-tempo-setup) (defun org-tempo-add-tempo (entry) "Add entries from `org-structure-template-alist'" (let* ((key (format "<%s" (char-to-string (car entry)))) (name (cdr entry))) (if (assoc-string key org-tempo-tags) (setq org-tempo-tags (delete (assoc-string key org-tempo-tags) org-tempo-tags))) (tempo-define-template (format "org-%s" (replace-regexp-in-string " " "= -" name)) `(,(format "#+begin_%s " name) p '> n n ,(format "#+end_%s" (car (org-split-string name " "))) >) key (format "Insert a %s block" name) 'org-tempo-tags))) (mapcar 'org-tempo-add-tempo org-structure-template-alist) (tempo-define-template "org-include" '("#+include: " (ignore-errors (format "\"%s\" " (file-relative-name (read-file-name "Include file: = ")))) p >) "