aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-11-07 23:57:04 +0100
committerLars Ingebrigtsen2021-11-07 23:57:04 +0100
commit5f70682d7b8a3550bf6b9366329ad3418ab0a95f (patch)
treec928b7418d622af6ee045db6ea47faa88189eaf9 /lisp/textmodes
parentdde591571abfb92864609921ce7f5838c9d41785 (diff)
downloademacs-5f70682d7b8a3550bf6b9366329ad3418ab0a95f.tar.gz
emacs-5f70682d7b8a3550bf6b9366329ad3418ab0a95f.zip
Allow 'C-x n d' to work in texinfo-mode
* lisp/textmodes/texinfo.el (texinfo-mode): Set beginning/end-of-defun functions to allow narrowing to the current node. (texinfo--beginning-of-defun, texinfo--end-of-defun): New functions.
Diffstat (limited to 'lisp/textmodes')
-rw-r--r--lisp/textmodes/texinfo.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el
index 3ddd9040657..71db33bae35 100644
--- a/lisp/textmodes/texinfo.el
+++ b/lisp/textmodes/texinfo.el
@@ -416,6 +416,8 @@ value of `texinfo-mode-hook'."
416 (setq-local fill-paragraph-function 'texinfo--fill-paragraph) 416 (setq-local fill-paragraph-function 'texinfo--fill-paragraph)
417 (setq-local sentence-end-base "\\(@\\(end\\)?dots{}\\|[.?!]\\)[]\"'”)}]*") 417 (setq-local sentence-end-base "\\(@\\(end\\)?dots{}\\|[.?!]\\)[]\"'”)}]*")
418 (setq-local fill-column 70) 418 (setq-local fill-column 70)
419 (setq-local beginning-of-defun-function #'texinfo--beginning-of-defun)
420 (setq-local end-of-defun-function #'texinfo--end-of-defun)
419 (setq-local comment-start "@c ") 421 (setq-local comment-start "@c ")
420 (setq-local comment-start-skip "@c +\\|@comment +") 422 (setq-local comment-start-skip "@c +\\|@comment +")
421 (setq-local words-include-escapes t) 423 (setq-local words-include-escapes t)
@@ -494,6 +496,20 @@ value of `texinfo-mode-hook'."
494 (fill-paragraph justify)))) 496 (fill-paragraph justify))))
495 t)) 497 t))
496 498
499(defun texinfo--beginning-of-defun (&optional arg)
500 "Go to the previous @node line."
501 (while (and (> arg 0)
502 (re-search-backward "^@node " nil t))
503 (setq arg (1- arg))))
504
505(defun texinfo--end-of-defun ()
506 "Go to the start of the next @node line."
507 (when (looking-at-p "@node")
508 (forward-line))
509 (if (re-search-forward "^@node " nil t)
510 (goto-char (match-beginning 0))
511 (goto-char (point-max))))
512
497 513
498;;; Insert string commands 514;;; Insert string commands
499 515