From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: function for inserting a block Date: Sat, 02 Sep 2017 17:25:30 -0700 Message-ID: <877exghblx.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1doIjl-0005Y3-Kc for emacs-orgmode@gnu.org; Sat, 02 Sep 2017 20:26:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1doIjg-000191-Vt for emacs-orgmode@gnu.org; Sat, 02 Sep 2017 20:26:05 -0400 Received: from [195.159.176.226] (port=47121 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1doIjg-00015o-OM for emacs-orgmode@gnu.org; Sat, 02 Sep 2017 20:26:00 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1doIjK-0002V4-I4 for emacs-orgmode@gnu.org; Sun, 03 Sep 2017 02:25:38 +0200 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 The easy template entry thing is useful as far as it goes, but for some reason I find myself "marking up" existing text in Org as least as often as I'm writing new text from scratch. I've always wanted a "wrap region in block" command, and finally wrote one. Don't know why it took me so long. Would something like this be attractive for inclusion in Org? (defun org-insert-structure-template (type start end) "Insert a block structure as in #+BEGIN_TYPE/#+END_TYPE. Prompts for a block TYPE, and inserts the block. With an active region, wrap the region in the block." (interactive "sBlock type: \nr") (let ((s (set-marker (make-marker) start)) (e (set-marker (make-marker) end))) (goto-char s) (goto-char (line-beginning-position)) (insert (format "#+BEGIN_%s\n" (upcase type))) (goto-char e) (goto-char (line-end-position)) (insert (format "\n#+END_%s" (upcase type))))) Other possibilities: - A "close current block" command, a la `sgml-close-tag'. Inserts a #+END_FOO tag if needed. - Provide completion for the block type prompt, though that might create some redundancy with `org-structure-template-alist'. If this is acceptable, I'd like to bind it to "C-c i", and would provide docs. Eric