Skip to content

Instantly share code, notes, and snippets.

@bmc
Created August 30, 2011 15:11
Show Gist options
  • Save bmc/1181122 to your computer and use it in GitHub Desktop.
Save bmc/1181122 to your computer and use it in GitHub Desktop.
Making my Scaladoc tombstones conform
; I've been trying to convert my Scaladoc comments from Java style to Scala style.
; i.e., from:
; /**
; * This amazing method washes your hair, trims your beard, and
; * and brushes your teeth.
; */
;
; to:
;
; /** This amazing method washes your hair, trims your beard, and
; * and brushes your teeth.
; */
;
; This Emacs LISP function helps.
(defun scedit ()
(interactive)
(save-excursion
(beginning-of-buffer)
(replace-regexp "/\\*\\*
+\\*" "/**" nil (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)))
(beginning-of-buffer)
(replace-regexp "^\\( *\\)\\*" "\\1 *" nil (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)))
(beginning-of-buffer)
(replace-regexp "\\* +<li>" "* - " nil (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)))
(beginning-of-buffer)
(replace-regexp "</?tt>" "`" nil (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)))
(beginning-of-buffer)
(replace-regexp "</?p>" "" nil (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)))
(beginning-of-buffer)
(replace-regexp "</?i>" "''" nil (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)))
(beginning-of-buffer)
(replace-regexp "</?b>" "'''" nil (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)))
(beginning-of-buffer)
(replace-regexp "</?u>" "__" nil (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment