changeset 85858:0745c5662909

(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.
author Glenn Morris <rgm@gnu.org>
date Thu, 01 Nov 2007 04:00:09 +0000
parents 84fe4e940d8d
children 5c531755dfac
files lisp/textmodes/nroff-mode.el
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/nroff-mode.el	Thu Nov 01 03:53:44 2007 +0000
+++ b/lisp/textmodes/nroff-mode.el	Thu Nov 01 04:00:09 2007 +0000
@@ -132,6 +132,7 @@
   (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 ()
@@ -163,6 +164,19 @@
 			      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.
@@ -175,7 +189,7 @@
       (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.