From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Outline cycling does not preserve point's position Date: Tue, 10 Sep 2013 20:39:09 +0200 Message-ID: <8761u88qsy.fsf@gmail.com> References: <87d2oi57fg.fsf@gmail.com> <7CB7B681-DD2E-446C-AE45-DDCA204EE95C@gmail.com> <5855E8E1-9730-4A29-89FF-E35C64E54EDD@gmail.com> <20130910073257.GO20690@kuru.dyndns-at-home.com> <20130910075345.GP20690@kuru.dyndns-at-home.com> <25A21DB7-B2E5-47BB-8A64-594A15CB24B8@gmail.com> <20130910085057.GQ20690@kuru.dyndns-at-home.com> <4ED2509E-8A2E-4ED2-BFCF-CB7B27F1D2B4@gmail.com> <20130910095043.GR20690@kuru.dyndns-at-home.com> <87a9jk8wmr.fsf@gmail.com> <878uz4a5iq.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJSq9-00029E-Tu for emacs-orgmode@gnu.org; Tue, 10 Sep 2013 14:39:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJSq1-0001X7-GO for emacs-orgmode@gnu.org; Tue, 10 Sep 2013 14:39:05 -0400 Received: from mail-ee0-x235.google.com ([2a00:1450:4013:c00::235]:35085) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJSq1-0001X2-9M for emacs-orgmode@gnu.org; Tue, 10 Sep 2013 14:38:57 -0400 Received: by mail-ee0-f53.google.com with SMTP id b15so4110100eek.40 for ; Tue, 10 Sep 2013 11:38:56 -0700 (PDT) In-Reply-To: <878uz4a5iq.fsf@gmail.com> (Jambunathan K.'s message of "Wed, 11 Sep 2013 00:05:57 +0530") 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: Jambunathan K Cc: emacs-orgmode@gnu.org, Carsten Dominik Hello, Jambunathan K writes: > Nicolas Goaziou writes: > >> Here's a first draft for the linear forward motion. > > cond: Symbol's function definition is void: > org-forward-and-down-element Hmm. That's a silly mistake (few aren't): I changed its name as a second thought and forgot to update the recursive calls. Thanks. Take 2: (defun org-forward-linear-element () (interactive) (when (eobp) (user-error "Cannot move further down")) (let* ((origin (point)) (element (org-element-at-point)) (type (org-element-type element)) (contents-begin (org-element-property :contents-begin element)) (contents-end (org-element-property :contents-end element)) (end (let ((end (org-element-property :end element)) (parent element)) (while (and (setq parent (org-element-property :parent parent)) (= (org-element-property :contents-end parent) end)) (setq end (org-element-property :end parent))) end))) (skip-chars-forward " \r\t\n") (or (eobp) (goto-char (max (line-beginning-position) origin))) (cond ((or (eobp) (= (point) end))) ((not contents-begin) (goto-char end)) ((< (point) contents-begin) (cond ((eq type 'item) (end-of-line) (org-forward-linear-element)) ((eq type 'table-row) (goto-char end)) (t (goto-char contents-begin)))) ((>= (point) contents-end) (goto-char end)) ((eq type 'paragraph) (goto-char end)) ((eq type 'plain-list) (end-of-line) (org-forward-linear-element)) ((eq type 'table) (forward-line) (when (>= (point) contents-end) (goto-char end))) ((eq type 'verse-block) (or (re-search-forward "^[ \t]*$" contents-end t) (goto-char end))) (t (error "This shouldn't happen"))) (when (org-invisible-p2) (goto-char end)))) Regards, -- Nicolas Goaziou