emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: prayner <prayner@unimelb.edu.au>
Cc: emacs-orgmode@gnu.org
Subject: Re: patch to add org-table-previous-row to org-table
Date: Wed, 22 Jul 2015 10:32:59 +0200	[thread overview]
Message-ID: <87si8gzj5w.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <21912.25165.91884.664853@localhost.localdomain> (prayner@unimelb.edu.au's message of "Sun, 5 Jul 2015 08:46:37 +1000")

Hello,

prayner <prayner@unimelb.edu.au> writes:

> I am working with the accessibility system emacspeak to improve
> eyes-free access to org-mode tables. Most of this can be done outside
> the org-mode tree by advising existing functions but I've run into a
> need for a new function. I need org-table-previous-row analogous to
> org-table-next-row. Below is a patch to add this. The behaviour is
> almost identical to org-table-next-row except that
> org-table-previous-row in the first row of the table is a no-op.
> Please consider adding this to the repository. Comments and
> corrections welcome but please send them to me directly as well as the
> list.

Thanks for the patch.  

I think it introduces too much code duplication with
`org-table-next-row'. We could extend this function to accept a numeric
argument, then `org-table-previous-row' would just be
`org-table-next-row' called with a negative argument.

> +(defun org-table-previous-row ()
> +  "Go to the previous row (same column) in the current table.
> +Before doing so, re-align the table if necessary."
> +  (interactive)
> +  (org-table-maybe-eval-formula)
> +  (org-table-maybe-recalculate-line)
> +  (if (or (looking-at "[ \t]*$")
> +	  (save-excursion (skip-chars-backward " \t") (bolp)))
> +      (newline)

This part is incorrect because, unlike to `org-table-next-row',
`org-table-previous-row' is not meant to add rows.

> +    (if (and org-table-automatic-realign
> +	     org-table-may-need-update)
> +	(org-table-align))
> +    (let ((col (org-table-current-column)))
> +      (beginning-of-line 0)

I find (forward-line -1) clearer.

> +      (if (or (not (org-at-table-p))
> +	      (org-at-table-hline-p))
> +	  (progn
> +	    (beginning-of-line 1)))

(when (or ...) (beginning-of-line))

> +      (org-table-goto-column col)
> +      (skip-chars-backward "^|\n\r")
> +      (if (looking-at " ") (forward-char 1))

(when (org-looking-at " ") (forward-char))


Regards,

-- 
Nicolas Goaziou

      reply	other threads:[~2015-07-22  8:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-04 22:46 patch to add org-table-previous-row to org-table prayner
2015-07-22  8:32 ` Nicolas Goaziou [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87si8gzj5w.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=prayner@unimelb.edu.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).