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 18:33:16 +0200 Message-ID: <87a9jk8wmr.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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJQsN-0000GP-TN for emacs-orgmode@gnu.org; Tue, 10 Sep 2013 12:33:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJQsE-00064u-1n for emacs-orgmode@gnu.org; Tue, 10 Sep 2013 12:33:15 -0400 Received: from mail-ee0-x22e.google.com ([2a00:1450:4013:c00::22e]:39559) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJQsD-00064f-NP for emacs-orgmode@gnu.org; Tue, 10 Sep 2013 12:33:05 -0400 Received: by mail-ee0-f46.google.com with SMTP id c13so3542404eek.19 for ; Tue, 10 Sep 2013 09:33:04 -0700 (PDT) In-Reply-To: <20130910095043.GR20690@kuru.dyndns-at-home.com> (Suvayu Ali's message of "Tue, 10 Sep 2013 11:50:43 +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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Suvayu Ali Cc: emacs-orgmode@gnu.org, Carsten Dominik Hello, Suvayu Ali writes: > On Tue, Sep 10, 2013 at 11:02:35AM +0200, Carsten Dominik wrote: >>=20 >> On 10.9.2013, at 10:50, Suvayu Ali wrote: >>=20 >> > On Tue, Sep 10, 2013 at 10:16:06AM +0200, Carsten Dominik wrote: >> >>=20 >> >> The question is: What are people using C-arrow for? >> >>=20 >> >> I think the main application is reasonably fast motion >> >> and selection in a *linear* way. Is this correct, or do people >> >> disagree here with me? >> >=20 >> > I use it for navigating a buffer (not necessarily Org) linearly; i.e. = go >> > back and forth between parts I'm working on or to peruse the contents = of >> > a file. That said, often I feel the need for a navigation command whi= ch >> > allows me to navigate the semantics of the buffer (which exactly what >> > Nicolas's elements based navigation does). >> >=20 >> >> The amazing element motion commands Nicolas has implement >> >> correspond to sexp motion, as he has said himself. >> >> Maybe C-M-f and C-M-b are the better binding match for these? >> >=20 >> > I think you are right here. There is a need for both. For me, I use >> > linear navigation more commonly; so I would prefer C- for >> > linear navigation and some other bindings (like C-M-f/b, as you sugges= t) >> > for the elements based motion. >>=20 >> And by linear, I think we don't mean strictly linear, but on a >> paragraph/table/item scale, ignoring hierarchy. > > Yes. However I think I differ a bit on items. For me in a list like > the following, I would call moving by paragraphs _within_ the list items > linear; so, "Lorem..." =E2=86=92 "Cras..." =E2=86=92 "Integer..." =E2=86= =92 "Aenean..." =E2=86=92 > "Pellentesque...", and so on. Here's a first draft for the linear forward motion. Disclaimer: I didn't test it thoroughly. (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 ele= ment)) (while (and (setq parent (org-element-property :parent pa= rent)) (=3D (org-element-property :contents-end pare= nt) 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) (=3D (point) end))) ((not contents-begin) (goto-char end)) ((< (point) contents-begin) (cond ((eq type 'item) (end-of-line) (org-forward-and-down-element)) ((eq type 'table-row) (goto-char end)) (t (goto-char contents-begin)))) ((>=3D (point) contents-end) (goto-char end)) ((eq type 'paragraph) (goto-char end)) ((eq type 'plain-list) (end-of-line) (org-forward-and-down-element)) ((eq type 'table) (forward-line) (when (>=3D (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)))) WDYT? Regards, --=20 Nicolas Goaziou