├── README.md ├── elisp-docstring-mode.el └── images └── demo.png /README.md: -------------------------------------------------------------------------------- 1 | # elisp-docstring-mode 2 | 3 | A simple major-mode for editing content of Emacs Lisp docstrings. Very useful in combination with [string-edit](https://github.com/magnars/string-edit.el). 4 | 5 | # Features 6 | 7 | Provides font-lock. In combination with string-edit, there is support for automatic escaping and unescaping of quotes. 8 | 9 | Here is a comparison of the string as a docstring in `emacs-lisp-mode` and as a string in a `string-edit` buffer (with `elisp-docstring-mode` enabled). 10 | 11 | ![demo](images/demo.png) 12 | -------------------------------------------------------------------------------- /elisp-docstring-mode.el: -------------------------------------------------------------------------------- 1 | ;;; elisp-docstring-mode.el --- Major mode for editing elisp docstrings. 2 | 3 | ;; Copyright (C) 2017 Matúš Goljer 4 | 5 | ;; Author: Matúš Goljer 6 | ;; Maintainer: Matúš Goljer 7 | ;; Version: 0.0.1 8 | ;; Created: 4th March 2017 9 | ;; Package-requires: () 10 | ;; Keywords: languages 11 | 12 | ;; This program is free software; you can redistribute it and/or 13 | ;; modify it under the terms of the GNU General Public License 14 | ;; as published by the Free Software Foundation; either version 3 15 | ;; of the License, or (at your option) any later version. 16 | 17 | ;; This program is distributed in the hope that it will be useful, 18 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | ;; GNU General Public License for more details. 21 | 22 | ;; You should have received a copy of the GNU General Public License 23 | ;; along with this program. If not, see . 24 | 25 | ;;; Commentary: 26 | 27 | ;;; Code: 28 | 29 | (defun elisp-docstring-mode--find-variable (limit) 30 | "Find an occurrence of a variable name. 31 | Search up to LIMIT." 32 | (and (re-search-forward "\\_<[A-Z]+\\_>" limit) 33 | (not (nth 3 (syntax-ppss))))) 34 | 35 | (defvar elisp-docstring-mode-font-lock-keywords 36 | '( 37 | ;; Words inside \[] tend to be for `substitute-command-keys'. 38 | ("\\\\\\[\\(\\(?:\\sw\\|\\s_\\)+\\)\\]" 0 font-lock-keyword-face prepend) 39 | ;; Words inside `' tend to be symbol names. 40 | ("`\\(\\(?:\\sw\\|\\s_\\)\\(?:\\sw\\|\\s_\\)+\\)'" 0 font-lock-constant-face prepend) 41 | ;; there are some false-positives, but for now this is good enough 42 | (elisp-docstring-mode--find-variable 0 font-lock-variable-name-face prepend)) 43 | "Keywords for `font-lock-mode'.") 44 | 45 | ;;;###autoload 46 | (define-derived-mode elisp-docstring-mode text-mode 47 | "Elisp docstring mode" 48 | "Major mode for editing Emacs Lisp docstrings." 49 | (set (make-local-variable 'font-lock-defaults) 50 | '((elisp-docstring-keywords elisp-docstring-mode-font-lock-keywords))) 51 | (modify-syntax-entry ?\" "\"")) 52 | 53 | (provide 'elisp-docstring-mode) 54 | ;;; elisp-docstring-mode.el ends here 55 | -------------------------------------------------------------------------------- /images/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fuco1/elisp-docstring-mode/f512e509dd690f65133e55563ebbfd2dede5034f/images/demo.png --------------------------------------------------------------------------------