summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor R Campbell <campbell+paredit@mumble.net>2019-11-21 23:28:41 +0000
committerTaylor R Campbell <campbell+paredit@mumble.net>2019-11-21 23:28:41 +0000
commit814999bb320e6d5aaa9c8ff663b1933157129571 (patch)
tree8180c5299aaf83305fad88df872b708a6922db39
parentb1c332a24a258028fd388d4a0b71052807691a1c (diff)
New variables for comment prefixes.
You can customize these according to mode if your Lisp has different style conventions from the Common Lisp and Scheme in my experience.
-rw-r--r--paredit.el15
-rw-r--r--test.el81
2 files changed, 93 insertions, 3 deletions
diff --git a/paredit.el b/paredit.el
index 477d616..fd9f038 100644
--- a/paredit.el
+++ b/paredit.el
@@ -1107,6 +1107,15 @@ If a list begins on the line after the point but ends on a different
(defalias 'paredit-initialize-comment-dwim 'comment-normalize-vars)
(comment-normalize-vars))
+(defvar paredit-comment-prefix-toplevel ";;; "
+ "String of prefix for top-level comments aligned at the left margin.")
+
+(defvar paredit-comment-prefix-code ";; "
+ "String of prefix for comments indented at the same depth as code.")
+
+(defvar paredit-comment-prefix-margin ";"
+ "String of prefix for comments on the same line as code in the margin.")
+
(defun paredit-comment-dwim (&optional argument)
"Call the Lisp comment command you want (Do What I Mean).
This is like `comment-dwim', but it is specialized for Lisp editing.
@@ -1168,13 +1177,13 @@ This is expected to be called only in `paredit-comment-dwim'; do not
(and indent (zerop indent))))
;; Top-level comment
(if code-after-p (save-excursion (newline)))
- (insert ";;; "))
+ (insert paredit-comment-prefix-toplevel))
((or code-after-p (not code-before-p))
;; Code comment
(if code-before-p
(newline-and-indent)
(lisp-indent-line))
- (insert ";; ")
+ (insert paredit-comment-prefix-code)
(if code-after-p
(save-excursion
(newline)
@@ -1183,7 +1192,7 @@ This is expected to be called only in `paredit-comment-dwim'; do not
(t
;; Margin comment
(indent-to comment-column 1) ; 1 -> force one leading space
- (insert ?\; )))))
+ (insert paredit-comment-prefix-margin)))))
;;;; Character Deletion
diff --git a/test.el b/test.el
index ad7ab56..9b2a056 100644
--- a/test.el
+++ b/test.el
@@ -1417,3 +1417,84 @@ Four arguments: the paredit command, the text of the buffer
"(let ((x 5))\n |(foo bar\n baz)\n (wrong indent))")
("(define (f x #!optional\n (|wrong indent))\n (+ 1 2))"
"(define (f x #!optional\n |wrong)\n (+ 1 2))")))
+
+(let ((paredit-comment-prefix-toplevel ";;;T ")
+ (paredit-comment-prefix-code ";;C ")
+ (paredit-comment-prefix-margin ";M "))
+ (paredit-test 'paredit-comment-dwim
+ '(("|\n(f xy\n z\n w)\n"
+ ";;;T |\n(f xy\n z\n w)\n"
+ ";;;|T \n(f xy\n z\n w)\n"
+ ";;;|T \n(f xy\n z\n w)\n")
+ ("\n|(f xy\n z\n w)\n"
+ "\n;;;T |\n(f xy\n z\n w)\n"
+ "\n;;;|T \n(f xy\n z\n w)\n"
+ "\n;;;|T \n(f xy\n z\n w)\n")
+ ("\n(|f xy\n z\n w)\n"
+ "\n(\n ;;C |\n f xy\n z\n w)\n"
+ "\n(\n ;;|C \n f xy\n z\n w)\n"
+ "\n(\n ;;|C \n f xy\n z\n w)\n")
+ ("\n(f| xy\n z\n w)\n"
+ "\n(f\n ;;C |\n xy\n z\n w)\n"
+ "\n(f\n ;;|C \n xy\n z\n w)\n"
+ "\n(f\n ;;|C \n xy\n z\n w)\n")
+ ("\n(f |xy\n z\n w)\n"
+ "\n(f\n ;;C |\n xy\n z\n w)\n"
+ "\n(f\n ;;|C \n xy\n z\n w)\n"
+ "\n(f\n ;;|C \n xy\n z\n w)\n")
+ ("\n(f x|y\n z\n w)\n"
+ "\n(f x\n ;;C |\n y\n z\n w)\n"
+ "\n(f x\n ;;|C \n y\n z\n w)\n"
+ "\n(f x\n ;;|C \n y\n z\n w)\n")
+ ("\n(f xy|\n z\n w)\n"
+ "\n(f xy ;M |\n z\n w)\n"
+ "\n(f xy ;|M \n z\n w)\n"
+ "\n(f xy ;|M \n z\n w)\n")
+ ("\n(f xy\n| z\n w)\n"
+ "\n(f xy\n ;;C |\n z\n w)\n"
+ "\n(f xy\n ;;|C \n z\n w)\n"
+ "\n(f xy\n ;;|C \n z\n w)\n")
+ ("\n(f xy\n | z\n w)\n"
+ "\n(f xy\n ;;C |\n z\n w)\n"
+ "\n(f xy\n ;;|C \n z\n w)\n"
+ "\n(f xy\n ;;|C \n z\n w)\n")
+ ("\n(f xy\n | z\n w)\n"
+ "\n(f xy\n ;;C |\n z\n w)\n"
+ "\n(f xy\n ;;|C \n z\n w)\n"
+ "\n(f xy\n ;;|C \n z\n w)\n")
+ ("\n(f xy\n |z\n w)\n"
+ "\n(f xy\n ;;C |\n z\n w)\n"
+ "\n(f xy\n ;;|C \n z\n w)\n"
+ "\n(f xy\n ;;|C \n z\n w)\n")
+ ("\n(f xy\n z|\n w)\n"
+ "\n(f xy\n z ;M |\n w)\n"
+ "\n(f xy\n z ;|M \n w)\n"
+ "\n(f xy\n z ;|M \n w)\n")
+ ("\n(f xy\n z\n| w)\n"
+ "\n(f xy\n z\n ;;C |\n w)\n"
+ "\n(f xy\n z\n ;;|C \n w)\n"
+ "\n(f xy\n z\n ;;|C \n w)\n")
+ ("\n(f xy\n z\n | w)\n"
+ "\n(f xy\n z\n ;;C |\n w)\n"
+ "\n(f xy\n z\n ;;|C \n w)\n"
+ "\n(f xy\n z\n ;;|C \n w)\n")
+ ("\n(f xy\n z\n | w)\n"
+ "\n(f xy\n z\n ;;C |\n w)\n"
+ "\n(f xy\n z\n ;;|C \n w)\n"
+ "\n(f xy\n z\n ;;|C \n w)\n")
+ ("\n(f xy\n z\n |w)\n"
+ "\n(f xy\n z\n ;;C |\n w)\n"
+ "\n(f xy\n z\n ;;|C \n w)\n"
+ "\n(f xy\n z\n ;;|C \n w)\n")
+ ("\n(f xy\n z\n w|)\n"
+ "\n(f xy\n z\n w\n ;;C |\n )\n"
+ "\n(f xy\n z\n w\n ;;|C \n )\n"
+ "\n(f xy\n z\n w\n ;;|C \n )\n")
+ ("\n(f xy\n z\n w)|\n"
+ "\n(f xy\n z\n w) ;M |\n"
+ "\n(f xy\n z\n w) ;|M \n"
+ "\n(f xy\n z\n w) ;|M \n")
+ ("\n(f xy\n z\n w)\n|"
+ "\n(f xy\n z\n w)\n;;;T |"
+ "\n(f xy\n z\n w)\n;;;|T "
+ "\n(f xy\n z\n w)\n;;;|T ")))) \ No newline at end of file