From: Robert Weiner <rsw@gnu.org>
To: 23985@debbugs.gnu.org, bug-texinfo@gnu.org
Subject: bug#23985: Emacs 25.0.94: FEATURE ADDITION: Texinfo environment movement commands
Date: Thu, 14 Jul 2016 12:19:46 -0400 [thread overview]
Message-ID: <CA+OMD9h4K37aErqGFRsK9-F1JOUyPY+hLSyZQv7_fdY-qaw9HA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 879 bytes --]
The attached patch adds movement commands for texinfo-mode that move
between the start and end of single-level environments (things that
end with an @end line), e.g. @table.
(define-key map "\C-c." 'texinfo-to-environment-bounds) -
when within an environment, moves between the start and end lines
(define-key map "\C-c\C-c\C-f" 'texinfo-next-environment-end) -
from anywhere, moves to the next end line of an environment
(define-key map "\C-c\C-c\C-b" 'texinfo-previous-environment-end)
- from anywhere, moves to the previous end line of an environment
(define-key map "\C-c\C-c\C-n" 'texinfo-next-environment-start) -
from anywhere, moves to the next start line of an environment
(define-key map "\C-c\C-c\C-p"
'texinfo-previous-environment-start) - from anywhere, moves to the
previous start line of an environment
See attached for the patch.
[-- Attachment #2: texinfo.el.patch --]
[-- Type: application/octet-stream, Size: 3508 bytes --]
*** texinfo-orig.el 2016-07-14 12:06:08.000000000 -0400
--- texinfo.el 2016-07-14 12:06:08.000000000 -0400
***************
*** 480,485 ****
--- 480,492 ----
(define-key map "\C-c\C-ce" 'texinfo-insert-@end)
(define-key map "\C-c\C-cd" 'texinfo-insert-@dfn)
(define-key map "\C-c\C-cc" 'texinfo-insert-@code)
+
+ ;; bindings for environment movement
+ (define-key map "\C-c." 'texinfo-to-environment-bounds)
+ (define-key map "\C-c\C-c\C-f" 'texinfo-next-environment-end)
+ (define-key map "\C-c\C-c\C-b" 'texinfo-previous-environment-end)
+ (define-key map "\C-c\C-c\C-n" 'texinfo-next-environment-start)
+ (define-key map "\C-c\C-c\C-p" 'texinfo-previous-environment-start)
map))
(easy-menu-define texinfo-mode-menu
***************
*** 1032,1037 ****
--- 1039,1111 ----
;; job-number"\n"))
(tex-recenter-output-buffer nil))
+ ;;; Texinfo environment, e.g. @table, movement commands
+ ;; Author: Bob Weiner <rsw@gnu.org>, Orig-Date: 7/14/2016
+ ;; Copyright (C) 2016 Free Software Foundation, Inc.
+
+ (defun texinfo-to-environment-bounds ()
+ "If within a Texinfo environment with an @end, move point first to its starting line and then to its ending line.
+ Do nothing when outside of an environment; this does not handle nested environments."
+ (interactive)
+ (cond ((save-excursion
+ (forward-line 0)
+ (looking-at texinfo-environment-regexp))
+ (if (save-excursion
+ (forward-line 0)
+ (looking-at "^@end"))
+ (texinfo-previous-environment-start)
+ (texinfo-next-environment-end)))
+ ((save-excursion
+ (and (re-search-backward texinfo-environment-regexp nil t)
+ (not (looking-at "^@end"))))
+ (texinfo-previous-environment-start))
+ ;; Otherwise, point is outside of an environment, so do nothing.
+ ))
+
+ (defun texinfo-next-environment-start ()
+ "Move forward to the beginning of a Texinfo environment that ends with an @end."
+ (interactive)
+ (if (looking-at texinfo-environment-regexp)
+ (forward-line 1))
+ (while (and (re-search-forward texinfo-environment-regexp nil t)
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (looking-at "@end"))))
+ (if (save-excursion
+ (forward-line 0)
+ (looking-at texinfo-environment-regexp))
+ (forward-line 0)))
+
+ (defun texinfo-previous-environment-start ()
+ "Move back to the beginning of the previous Texinfo environment that ends with an @end."
+ (interactive)
+ (while (and (re-search-backward texinfo-environment-regexp nil t)
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (looking-at "@end")))))
+
+ (defun texinfo-next-environment-end ()
+ "Move forward to the beginning of the next @end line of a Texinfo environment."
+ (interactive)
+ (if (looking-at "^@end")
+ (forward-line 1))
+ (while (and (re-search-forward texinfo-environment-regexp nil t)
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (not (looking-at "^@end")))))
+ (if (save-excursion
+ (forward-line 0)
+ (looking-at "^@end"))
+ (forward-line 0)))
+
+ (defun texinfo-previous-environment-end ()
+ "Move backward to the beginning of the next @end line of a Texinfo environment."
+ (interactive)
+ (while (and (re-search-backward texinfo-environment-regexp nil t)
+ (save-excursion
+ (goto-char (match-beginning 0))
+ (not (looking-at "@end"))))))
+
(provide 'texinfo)
;;; texinfo.el ends here
next reply other threads:[~2016-07-14 16:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-14 16:19 Robert Weiner [this message]
2016-07-14 16:52 ` bug#23985: Emacs 25.0.94: FEATURE ADDITION: Texinfo environment movement commands Clément Pit--Claudel
2016-07-14 19:19 ` Eli Zaretskii
[not found] ` <83poqg6n8l.fsf@gnu.org>
2016-07-14 19:43 ` Robert Weiner
[not found] ` <CA+OMD9j0WEkaNfJLUCVgRV-5EG=gG=3TXzJgnC57kd4KxfAn=A@mail.gmail.com>
2016-07-14 20:15 ` Clément Pit--Claudel
2016-07-15 7:01 ` Eli Zaretskii
2020-08-11 14:38 ` Lars Ingebrigtsen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+OMD9h4K37aErqGFRsK9-F1JOUyPY+hLSyZQv7_fdY-qaw9HA@mail.gmail.com \
--to=rsw@gnu.org \
--cc=23985@debbugs.gnu.org \
--cc=bug-texinfo@gnu.org \
--cc=rswgnu@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.