Elisp: Bracket CAP WORDS
Here's a command to add brackets to all CAPITAL WORDS.
(defun xah-bracket-caps () "add ‹› to CAPITALIZED WORDS, on selection or current text block. Example: Change value in PLIST of PROP to VAL becomes Change value in ‹PLIST› of ‹PROP› to ‹VAL› URL `http://ergoemacs.org/emacs/elisp_bracket_caps.html' Version 2020-04-19, 2021-01-07" (interactive) (let ($p $p2 (case-fold-search nil)) (if (use-region-p) (setq $p1 (region-beginning) $p2 (region-end)) (save-excursion (if (re-search-backward "\n[ \t]*\n" nil "move") (progn (re-search-forward "\n[ \t]*\n") (setq $p1 (point))) (setq $p1 (point))) (if (re-search-forward "\n[ \t]*\n" nil "move") (progn (re-search-backward "\n[ \t]*\n") (setq $p2 (point))) (setq $p2 (point))))) (save-restriction (narrow-to-region $p1 $p2) (goto-char (point-min)) (while (re-search-forward "\\b\\([A-Z][-A-Z0-9]+\\)\\b" nil t) (replace-match (concat "‹" (match-string 1) "›") t )))))
If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy
JavaScript in Depth