From 31cf791e20a025f5cde92a551b5751c972da451a Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Thu, 1 Nov 2007 04:03:12 +0000 Subject: [PATCH] (nroff-mode): Set indent-line-function. (nroff-indent-line-function): New function. (nroff-count-text-lines): Use nroff-forward-text-line rather than obsolete alias. --- lisp/ChangeLog | 5 +++++ lisp/textmodes/nroff-mode.el | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 37959364533..ce984fb410c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -21,6 +21,11 @@ (footnote-roman-lower-regexp, footnote-roman-upper-regexp): Match multi-character footnotes. + * textmodes/nroff-mode.el (nroff-mode): Set indent-line-function. + (nroff-indent-line-function): New function. + (nroff-count-text-lines): Use nroff-forward-text-line rather than + obsolete alias. + 2007-10-31 Michael Albinus * net/tramp.el (tramp-open-connection-telnet) diff --git a/lisp/textmodes/nroff-mode.el b/lisp/textmodes/nroff-mode.el index 18156071e1c..8297bb05827 100644 --- a/lisp/textmodes/nroff-mode.el +++ b/lisp/textmodes/nroff-mode.el @@ -130,6 +130,7 @@ closing requests for requests that are used in matched pairs." (set (make-local-variable 'comment-start-skip) "\\\\\"[ \t]*") (set (make-local-variable 'comment-column) 24) (set (make-local-variable 'comment-indent-function) 'nroff-comment-indent) + (set (make-local-variable 'indent-line-function) 'nroff-indent-line-function) (set (make-local-variable 'imenu-generic-expression) nroff-imenu-expression)) (defun nroff-outline-level () @@ -161,6 +162,19 @@ Puts a full-stop before comments on a line by themselves." 9) 8)))))) ; add 9 to ensure at least two blanks (goto-char pt)))) +;; All this does is insert a "." at the start of comment-lines, +;; for the sake of comment-dwim adding a new comment on an empty line. +;; Hack! The right fix probably involves ;; comment-insert-comment-function, +;; but comment-dwim does not call that for the empty line case. +;; http://lists.gnu.org/archive/html/emacs-devel/2007-10/msg01869.html +(defun nroff-indent-line-function () + "Function for `indent-line-function' in `nroff-mode'." + (save-excursion + (forward-line 0) + (when (looking-at "[ \t]*\\\\\"[ \t]*") ; \# does not need this + (delete-horizontal-space) + (insert ?.)))) + (defun nroff-count-text-lines (start end &optional print) "Count lines in region, except for nroff request lines. All lines not starting with a period are counted up. @@ -173,7 +187,7 @@ Noninteractively, return number of non-request lines from START to END." (save-restriction (narrow-to-region start end) (goto-char (point-min)) - (- (buffer-size) (forward-text-line (buffer-size))))))) + (- (buffer-size) (nroff-forward-text-line (buffer-size))))))) (defun nroff-forward-text-line (&optional cnt) "Go forward one nroff text line, skipping lines of nroff requests. -- 2.39.2