* patch to add org-table-previous-row to org-table
@ 2015-07-04 22:46 prayner
2015-07-22 8:32 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: prayner @ 2015-07-04 22:46 UTC (permalink / raw)
To: emacs-orgmode
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.
regards
Peter
----------------------------------------------------------------------
diff --git a/lisp/org-table.el b/lisp/org-table.el
index 8a6e22b..f17d84d 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -1092,6 +1092,30 @@ Before doing so, re-align the table if necessary."
(if (looking-at " ") (forward-char 1)))))
;;;###autoload
+(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)
+ (if (and org-table-automatic-realign
+ org-table-may-need-update)
+ (org-table-align))
+ (let ((col (org-table-current-column)))
+ (beginning-of-line 0)
+ (if (or (not (org-at-table-p))
+ (org-at-table-hline-p))
+ (progn
+ (beginning-of-line 1)))
+ (org-table-goto-column col)
+ (skip-chars-backward "^|\n\r")
+ (if (looking-at " ") (forward-char 1)))))
+
+
+;;;###autoload
(defun org-table-copy-down (n)
"Copy the value of the current field one row below.
----------------------------------------------------------------------
>
--
Peter Rayner
Leader, Clean Air and Urban Landscapes NESP hub.
room 343
School of Earth Sciences, University of Melbourne, 3010, Vic, Australia
tel: work: +61 (0)3 8344 9708; fax: +61 (0)3 8344 7761
mobile +61 402 752 379, skype: petermorag
mail-to: prayner@unimelb.edu.au
google scholar profile <http://scholar.google.com.au/citations?user=H3up71wAAAAJ&hl=en>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: patch to add org-table-previous-row to org-table
2015-07-04 22:46 patch to add org-table-previous-row to org-table prayner
@ 2015-07-22 8:32 ` Nicolas Goaziou
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2015-07-22 8:32 UTC (permalink / raw)
To: prayner; +Cc: emacs-orgmode
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-07-22 8:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-04 22:46 patch to add org-table-previous-row to org-table prayner
2015-07-22 8:32 ` Nicolas Goaziou
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).