From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: patch to add org-table-previous-row to org-table Date: Wed, 22 Jul 2015 10:32:59 +0200 Message-ID: <87si8gzj5w.fsf@nicolasgoaziou.fr> References: <21912.25165.91884.664853@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHpR4-00062f-Of for emacs-orgmode@gnu.org; Wed, 22 Jul 2015 04:31:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZHpR3-00040z-N2 for emacs-orgmode@gnu.org; Wed, 22 Jul 2015 04:31:30 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:49741) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHpR3-00040U-HZ for emacs-orgmode@gnu.org; Wed, 22 Jul 2015 04:31:29 -0400 In-Reply-To: <21912.25165.91884.664853@localhost.localdomain> (prayner@unimelb.edu.au's message of "Sun, 5 Jul 2015 08:46:37 +1000") 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: prayner Cc: emacs-orgmode@gnu.org Hello, prayner 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