]> code.delx.au - gnu-emacs/blobdiff - lisp/newcomment.el
Derive secrets-mode from special-mode
[gnu-emacs] / lisp / newcomment.el
index 765e60a5bcff7fb5577dc47fdcb413fcce66c2a5..80b52ed9561e673fda0cd8c482041cbb72429f9d 100644 (file)
@@ -1,6 +1,6 @@
 ;;; newcomment.el --- (un)comment regions of buffers -*- lexical-binding: t -*-
 
-;; Copyright (C) 1999-2015 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2016 Free Software Foundation, Inc.
 
 ;; Author: code extracted from Emacs-20's simple.el
 ;; Maintainer: Stefan Monnier <monnier@iro.umontreal.ca>
@@ -418,7 +418,6 @@ If UNP is non-nil, unquote nested comment markers."
   (setq cs (comment-string-strip cs t t))
   (setq ce (comment-string-strip ce t t))
   (when (and comment-quote-nested
-            comment-quote-nested-function
             (> (length ce) 0))
     (funcall comment-quote-nested-function cs ce unp)))
 
@@ -427,8 +426,8 @@ If UNP is non-nil, unquote nested comment markers."
 It expects to be called with the buffer narrowed to a single comment.
 It is used as a default for `comment-quote-nested-function'.
 
-The arguments CS and CE are regular expressions matching comment
-starting and ending delimiters respectively.
+The arguments CS and CE are strings matching comment starting and
+ending delimiters respectively.
 
 If UNP is non-nil, comments are unquoted instead.
 
@@ -991,6 +990,14 @@ comment markers."
          (goto-char (point-max))))))
   (set-marker end nil))
 
+(defun comment-make-bol-ws (len)
+  "Make a white-space string of width LEN for use at BOL.
+When `indent-tabs-mode' is non-nil, tab characters will be used."
+  (if (and indent-tabs-mode (> tab-width 0))
+      (concat (make-string (/ len tab-width) ?\t)
+             (make-string (% len tab-width) ? ))
+    (make-string len ? )))
+
 (defun comment-make-extra-lines (cs ce ccs cce min-indent max-indent &optional block)
   "Make the leading and trailing extra lines.
 This is used for `extra-line' style (or `box' style if BLOCK is specified)."
@@ -1026,8 +1033,8 @@ This is used for `extra-line' style (or `box' style if BLOCK is specified)."
          (setq cs (replace-match fill t t s)))
        (string-match re e)
        (setq ce (replace-match fill t t e))))
-    (cons (concat cs "\n" (make-string min-indent ? ) ccs)
-         (concat cce "\n" (make-string (+ min-indent eindent) ? ) ce))))
+    (cons (concat cs "\n" (comment-make-bol-ws min-indent) ccs)
+         (concat cce "\n" (comment-make-bol-ws (+ min-indent eindent)) ce))))
 
 (defmacro comment-with-narrowing (beg end &rest body)
   "Execute BODY with BEG..END narrowing.