From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Burgess Subject: [PATCH] org-capture-place-item better alignment for new lists. Date: Tue, 7 Oct 2014 11:56:11 +0100 Message-ID: <20141007105611.GC3627@embecosm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbSRK-00078X-DX for emacs-orgmode@gnu.org; Tue, 07 Oct 2014 06:56:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XbSRC-0006mc-UB for emacs-orgmode@gnu.org; Tue, 07 Oct 2014 06:56:22 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:40268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XbSRC-0006mV-PO for emacs-orgmode@gnu.org; Tue, 07 Oct 2014 06:56:14 -0400 Received: by mail-wi0-f176.google.com with SMTP id hi2so7396429wib.15 for ; Tue, 07 Oct 2014 03:56:13 -0700 (PDT) Received: from localhost (cust64-dsl91-135-5.idnet.net. [91.135.5.64]) by mx.google.com with ESMTPSA id mc4sm14284130wic.6.2014.10.07.03.56.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Oct 2014 03:56:12 -0700 (PDT) Content-Disposition: inline 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 Creating an entry in org-capture-templates of type item adds entries into a list, however, if the list is empty then the first list item will be indented to depth 0 (so hard on the left) like this: * Top Level ** Second Level - item #1 - item #2 - item #3 I prefer to indent content, including lists, to a level matching the parent, so something like this: * Top Level ** Second Level - item #1 - item #2 - item #3 The patch below changes org-capture-place-item so that, when starting a new list, the items are indented as in the second example above. The existing behaviour is maintained when adding additional items to a list, that is the indentation of new items will match the indentation on items already in the list. All feedback welcome, Thanks, Andrew lisp/org-capture.el (org-capture-place-item): When starting a new list use (1+ org-current-level) rather than just 0 for the indentation. This ensures new lists are indented under their parent element. --- lisp/org-capture.el | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 9e33d25..150ba1e 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1064,7 +1064,7 @@ may have been stored before." "Place the template as a new plain list item." (let* ((txt (org-capture-get :template)) (target-entry-p (org-capture-get :target-entry-p)) - (ind 0) + (ind (1+ (org-current-level))) beg end) (if (org-capture-get :exact-position) (goto-char (org-capture-get :exact-position)) @@ -1078,18 +1078,13 @@ may have been stored before." (if (org-capture-get :prepend) (progn (goto-char beg) - (if (org-list-search-forward (org-item-beginning-re) end t) - (progn - (goto-char (match-beginning 0)) - (setq ind (org-get-indentation))) - (goto-char end) - (setq ind 0))) + (when (org-list-search-forward (org-item-beginning-re) end t) + (goto-char (match-beginning 0)) + (setq ind (org-get-indentation)))) (goto-char end) - (if (org-list-search-backward (org-item-beginning-re) beg t) - (progn - (setq ind (org-get-indentation)) - (org-end-of-item)) - (setq ind 0)))) + (when (org-list-search-backward (org-item-beginning-re) beg t) + (setq ind (org-get-indentation)) + (org-end-of-item)))) ;; Remove common indentation (setq txt (org-remove-indentation txt)) ;; Make sure this is indeed an item -- 1.9.3