From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: [RFC] [PATCH] Introduce org-specific functions for (next/previous)-visible-heading Date: Mon, 19 Jan 2015 00:14:40 -0500 Message-ID: <871tmric73.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YD4fn-0000O1-EN for emacs-orgmode@gnu.org; Mon, 19 Jan 2015 00:14:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YD4fi-0004I7-FD for emacs-orgmode@gnu.org; Mon, 19 Jan 2015 00:14:47 -0500 Received: from mail-qa0-x234.google.com ([2607:f8b0:400d:c00::234]:50941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YD4fi-0004I3-9M for emacs-orgmode@gnu.org; Mon, 19 Jan 2015 00:14:42 -0500 Received: by mail-qa0-f52.google.com with SMTP id x12so22536734qac.11 for ; Sun, 18 Jan 2015 21:14:41 -0800 (PST) Received: from localhost (c-50-191-35-222.hsd1.pa.comcast.net. [50.191.35.222]) by mx.google.com with ESMTPSA id j21sm11484322qgd.36.2015.01.18.21.14.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Jan 2015 21:14:41 -0800 (PST) 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: Org-mode --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, By default, org uses outline-next-visible-heading and the -previous- variant for the C-c C-n and C-c C-p keys, which means these commands stop on inline tasks (since they don=E2=80=99t know to skip them). This se= ems incorrect. The attached patch adds inlinetask-aware org functions for these keys. Comments are welcome. Thanks, --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-new-functions-to-move-to-the-next-prev-headline-.patch >From e3a61ab42c6e3d411a955473535bac80d69e9d7e Mon Sep 17 00:00:00 2001 From: Aaron Ecay Date: Sun, 18 Jan 2015 23:57:55 -0500 Subject: [PATCH] Add new functions to move to the next/prev headline skipping inline tasks. * lisp/org.el (org-next-visible-heading): (org-previous-visible-heading): New functions. (org-speed-commands-default, org-mode-map): Use them. --- lisp/org.el | 67 +++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 1222a69..2e0335c 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -19420,34 +19420,38 @@ boundaries." (define-key org-mode-map [remap outline-promote] 'org-promote-subtree) (define-key org-mode-map [remap outline-demote] 'org-demote-subtree) (define-key org-mode-map [remap outline-insert-heading] 'org-ctrl-c-ret) +(define-key org-mode-map [remap outline-next-visible-heading] + 'org-next-visible-heading) +(define-key org-mode-map [remap outline-previous-visible-heading] + 'org-previous-visible-heading) ;; Outline functions from `outline-mode-prefix-map' that can not ;; be remapped in Org: -;; + ;; - the column "key binding" shows whether the Outline function is still ;; available in Org mode on the same key that it has been bound to in ;; Outline mode: ;; - "overridden": key used for a different functionality in Org mode ;; - else: key still bound to the same Outline function in Org mode -;; -;; | Outline function | key binding | Org replacement | -;; |------------------------------------+-------------+-----------------------| -;; | `outline-next-visible-heading' | `C-c C-n' | still same function | -;; | `outline-previous-visible-heading' | `C-c C-p' | still same function | -;; | `outline-up-heading' | `C-c C-u' | still same function | -;; | `outline-move-subtree-up' | overridden | better: org-shiftup | -;; | `outline-move-subtree-down' | overridden | better: org-shiftdown | -;; | `show-entry' | overridden | no replacement | -;; | `show-children' | `C-c C-i' | visibility cycling | -;; | `show-branches' | `C-c C-k' | still same function | -;; | `show-subtree' | overridden | visibility cycling | -;; | `show-all' | overridden | no replacement | -;; | `hide-subtree' | overridden | visibility cycling | -;; | `hide-body' | overridden | no replacement | -;; | `hide-entry' | overridden | visibility cycling | -;; | `hide-leaves' | overridden | no replacement | -;; | `hide-sublevels' | overridden | no replacement | -;; | `hide-other' | overridden | no replacement | + +;; | Outline function | key binding | Org replacement | +;; |------------------------------------+-------------+--------------------------| +;; | `outline-next-visible-heading' | `C-c C-n' | better: skip inlinetasks | +;; | `outline-previous-visible-heading' | `C-c C-p' | better: skip inlinetasks | +;; | `outline-up-heading' | `C-c C-u' | still same function | +;; | `outline-move-subtree-up' | overridden | better: org-shiftup | +;; | `outline-move-subtree-down' | overridden | better: org-shiftdown | +;; | `show-entry' | overridden | no replacement | +;; | `show-children' | `C-c C-i' | visibility cycling | +;; | `show-branches' | `C-c C-k' | still same function | +;; | `show-subtree' | overridden | visibility cycling | +;; | `show-all' | overridden | no replacement | +;; | `hide-subtree' | overridden | visibility cycling | +;; | `hide-body' | overridden | no replacement | +;; | `hide-entry' | overridden | visibility cycling | +;; | `hide-leaves' | overridden | no replacement | +;; | `hide-sublevels' | overridden | no replacement | +;; | `hide-other' | overridden | no replacement | ;; Make `C-c C-x' a prefix key (org-defkey org-mode-map "\C-c\C-x" (make-sparse-keymap)) @@ -19687,8 +19691,8 @@ boundaries." (defconst org-speed-commands-default '( ("Outline Navigation") - ("n" . (org-speed-move-safe 'outline-next-visible-heading)) - ("p" . (org-speed-move-safe 'outline-previous-visible-heading)) + ("n" . (org-speed-move-safe 'org-next-visible-heading)) + ("p" . (org-speed-move-safe 'org-previous-visible-heading)) ("f" . (org-speed-move-safe 'org-forward-heading-same-level)) ("b" . (org-speed-move-safe 'org-backward-heading-same-level)) ("F" . org-next-block) @@ -24090,6 +24094,25 @@ Stop at the first and last subheadings of a superior heading." (interactive "p") (org-forward-heading-same-level (if arg (- arg) -1) invisible-ok)) +(defun org-next-visible-heading (arg) + (interactive "p") + (if (< arg 0) + (beginning-of-line) + (end-of-line)) + (let ((sign + ;; Taken from `cl-signum' + (cond ((> arg 0) 1) ((< arg 0) -1) (t (error "Should not happen"))))) + (setq arg (abs arg)) + (dotimes (_i arg) + (outline-next-visible-heading sign) + (when (featurep 'org-inlinetask) + (while (org-inlinetask-in-task-p) + (outline-next-visible-heading sign)))))) + +(defun org-previous-visible-heading (arg) + (interactive "p") + (org-next-visible-heading (- arg))) + (defun org-next-block (arg &optional backward block-regexp) "Jump to the next block. With a prefix argument ARG, jump forward ARG many source blocks. -- 2.2.2 --=-=-= Content-Type: text/plain -- Aaron Ecay --=-=-=--