From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: [patch, koma-letter] Change of subject behavior Date: Wed, 18 Mar 2015 00:41:23 +0100 Message-ID: <877fufdwf0.fsf@gmx.us> References: <87d247h6eo.fsf@gmx.us> <87wq2f1gqz.fsf@nicolasgoaziou.fr> <87mw3bdyv4.fsf@gmx.us> <87bnjr1au0.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YY174-0005Hm-F2 for emacs-orgmode@gnu.org; Tue, 17 Mar 2015 19:41:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YY170-0000aq-9e for emacs-orgmode@gnu.org; Tue, 17 Mar 2015 19:41:30 -0400 Received: from mout.gmx.net ([212.227.15.18]:65185) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YY16z-0000ai-Vz for emacs-orgmode@gnu.org; Tue, 17 Mar 2015 19:41:26 -0400 Received: from x200s ([109.201.152.5]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0MLunc-1YbIN633PQ-007oG3 for ; Wed, 18 Mar 2015 00:41:24 +0100 In-Reply-To: <87bnjr1au0.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Wed, 18 Mar 2015 00:08:23 +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 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Nicolas Goaziou writes: >> I updated the patch. Perhaps the loop determination shod be moved to a >> separate function to keep the template clean. > > Yes, it needs to be factored out (maybe > `org-koma-letter--special-headline-p') since it is also used in > `org-koma-letter-headline'. What about > > (defun org-koma-letter--special-headline-p (h info) > (let ((special-tags (plist-get info :special-tags))) > (org-some (lambda (tag) (assoc-string tag special-tags)) > (org-export-get-tags h info)))) That's nice. I had forgotten about org-export-get-tags. >> + (:with-headline-opening nil nil >> org-koma-letter-headline-is-opening-maybe) > > I don't think this line is required. It feels more consistent to provide the check through the definition, but I'm not willing to pick a fight over this so it's back to just checking the variable. I have only tested the patch briefly as I need to actually produce a letter. But for the letter I'm writing export works fine. =E2=80=94Rasmus --=20 To err is human. To screw up 10=E2=81=B6 times per second, you need a compu= ter --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-org.el-Add-keyword-support-to-M-RET.patch >From ec5c3ed3f6e1e3cfec5f6264f7b30dbef745aeb4 Mon Sep 17 00:00:00 2001 From: rasmus Date: Wed, 19 Nov 2014 15:39:19 +0100 Subject: [PATCH] org.el: Add keyword-support to M-RET * org.el (org-insert-keyword): New function. (org-meta-return): May call `org-insert-keyword'. --- lisp/org.el | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index dbd2cb7..8862f16 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -21286,6 +21286,23 @@ number of stars to add." (forward-line))))))) (unless toggled (message "Cannot toggle heading from here")))) +(defun org-insert-keyword (&optional arg) + "Insert a new keyword at point. + +ARG may be used to specify a keyword. Otherwise the keyword is determined from the context. + +Mainly used for `org-meta-return'." + ;; Roughly based on + ;; TODO: Respect `org-M-RET-may-split-line'. + ;; TODO: Behave differently based on whether at beginning or + ;; end of line. E.g. M-RET at pos 0 adds line ABOVE. + + (interactive "P") + (let* ((elm (org-element-at-point)) + (key (or arg (and (eq 'keyword (org-element-type elm)) + (org-element-property :key elm))))) + (and key (insert (format "\n#+%s: " key))))) + (defun org-meta-return (&optional arg) "Insert a new heading or wrap a region in a table. Calls `org-insert-heading' or `org-table-wrap-region', depending @@ -21298,12 +21315,13 @@ on context. See the individual commands for more information." (when (eq type 'table-row) (setq element (org-element-property :parent element)) (setq type 'table)) - (if (and (eq type 'table) - (eq (org-element-property :type element) 'org) - (>= (point) (org-element-property :contents-begin element)) - (< (point) (org-element-property :contents-end element))) - (call-interactively 'org-table-wrap-region) - (call-interactively 'org-insert-heading))))) + (cond ((and (eq type 'table) + (eq (org-element-property :type element) 'org) + (>= (point) (org-element-property :contents-begin element)) + (< (point) (org-element-property :contents-end element))) + (call-interactively 'org-table-wrap-region)) + ((eq type 'keyword) (call-interactively 'org-insert-keyword)) + (t (call-interactively 'org-insert-heading)))))) ;;; Menu entries -- 2.1.3 --=-=-=--