Added comment-line.

Pascal J. Bourguignon [2016-06-13 14:07]
Added comment-line.
Filename
pjb-sources.el
diff --git a/pjb-sources.el b/pjb-sources.el
index 0dd3bf5..ca9115f 100644
--- a/pjb-sources.el
+++ b/pjb-sources.el
@@ -3541,6 +3541,34 @@ SProject Type: ")



+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defun comment-line (start end)
+  "Comments a region using the infamous 'line' boxing style:
+
+/*
+ * Like
+ * this.
+ */
+
+"
+  (interactive "r")
+  (save-excursion
+   ;; Insert end of comment:
+   (goto-char end)
+   (unless (bolp)
+     (insert "\n"))
+   (insert " */\n")
+
+   (with-marker (end end)
+     ;; Insert begin of comment:
+     (goto-char start)
+     (unless (bolp)
+       (insert "\n"))
+     (insert "/*\n")
+     ;; Add line header:
+     (replace-regexp "^" " * " nil (point) (- end 1)))))
+

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 (provide 'pjb-sources)
ViewGit