diff options
| author | Mark Oteiza | 2017-08-27 22:22:29 -0400 |
|---|---|---|
| committer | Mark Oteiza | 2017-08-27 22:40:52 -0400 |
| commit | 043a84702f3002d711784e5fe97c9ea8690b4cfa (patch) | |
| tree | 56fb30aa4fe9d1eed4c9e8af5f159a8e81718cac /lisp/textmodes | |
| parent | 9e79a31c09d673019be2a2c78bf8b7db89351819 (diff) | |
| download | emacs-043a84702f3002d711784e5fe97c9ea8690b4cfa.tar.gz emacs-043a84702f3002d711784e5fe97c9ea8690b4cfa.zip | |
Font-lock FDO desktop files correctly
Single and double quotes do not have a special meaning in
desktop files.
https://standards.freedesktop.org/desktop-entry-spec/latest/
* etc/NEWS: Mention new mode.
* lisp/files.el (auto-mode-alist): Split out an entry for handling
the .desktop extension with conf-desktop-mode.
* lisp/textmodes/conf-mode.el (conf-desktop-font-lock-keywords): New
variable with rules for booleans and format specifiers.
(conf-unix-mode): Remove desktop file entry example from docstring.
(conf-desktop-mode): New derived major mode.
Diffstat (limited to 'lisp/textmodes')
| -rw-r--r-- | lisp/textmodes/conf-mode.el | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el index b420aaa2467..d03ee5eb314 100644 --- a/lisp/textmodes/conf-mode.el +++ b/lisp/textmodes/conf-mode.el | |||
| @@ -262,6 +262,12 @@ This variable is best set in the file local variables, or through | |||
| 262 | ("\\_<false\\|true\\_>" 0 'font-lock-keyword-face)) | 262 | ("\\_<false\\|true\\_>" 0 'font-lock-keyword-face)) |
| 263 | "Keywords to highlight in Conf TOML mode.") | 263 | "Keywords to highlight in Conf TOML mode.") |
| 264 | 264 | ||
| 265 | (defvar conf-desktop-font-lock-keywords | ||
| 266 | `(,@conf-font-lock-keywords | ||
| 267 | ("\\_<false\\|true\\_>" 0 'font-lock-constant-face) | ||
| 268 | ("\\_<%[uUfFick%]\\_>" 0 'font-lock-constant-face)) | ||
| 269 | "Keywords to highlight in Conf Desktop mode.") | ||
| 270 | |||
| 265 | (defvar conf-assignment-sign ?= | 271 | (defvar conf-assignment-sign ?= |
| 266 | "Sign used for assignments (char or string).") | 272 | "Sign used for assignments (char or string).") |
| 267 | 273 | ||
| @@ -449,16 +455,7 @@ The optional arg FONT-LOCK is the value for FONT-LOCK-KEYWORDS." | |||
| 449 | ;;;###autoload | 455 | ;;;###autoload |
| 450 | (define-derived-mode conf-unix-mode conf-mode "Conf[Unix]" | 456 | (define-derived-mode conf-unix-mode conf-mode "Conf[Unix]" |
| 451 | "Conf Mode starter for Unix style Conf files. | 457 | "Conf Mode starter for Unix style Conf files. |
| 452 | Comments start with `#'. | 458 | Comments start with `#'. For details see `conf-mode'." |
| 453 | For details see `conf-mode'. Example: | ||
| 454 | |||
| 455 | # Conf mode font-locks this right on Unix and with \\[conf-unix-mode] | ||
| 456 | |||
| 457 | [Desktop Entry] | ||
| 458 | Encoding=UTF-8 | ||
| 459 | Name=The GIMP | ||
| 460 | Name[ca]=El GIMP | ||
| 461 | Name[cs]=GIMP" | ||
| 462 | (conf-mode-initialize "#")) | 459 | (conf-mode-initialize "#")) |
| 463 | 460 | ||
| 464 | ;;;###autoload | 461 | ;;;###autoload |
| @@ -677,6 +674,21 @@ value = \"some string\"" | |||
| 677 | (setq-local conf-assignment-column 0) | 674 | (setq-local conf-assignment-column 0) |
| 678 | (setq-local conf-assignment-sign ?=)) | 675 | (setq-local conf-assignment-sign ?=)) |
| 679 | 676 | ||
| 677 | ;;;###autoload | ||
| 678 | (define-derived-mode conf-desktop-mode conf-unix-mode "Conf[Desktop]" | ||
| 679 | "Conf Mode started for freedesktop.org Desktop files. | ||
| 680 | Comments start with `#' and \"assignments\" are with `='. | ||
| 681 | For details see `conf-mode'. | ||
| 682 | |||
| 683 | # Conf mode font-locks this correctly with \\[conf-desktop-mode] | ||
| 684 | [Desktop Entry] | ||
| 685 | Name=GNU Image Manipulation Program | ||
| 686 | Name[oc]=Editor d'imatge GIMP | ||
| 687 | Exec=gimp-2.8 %U | ||
| 688 | Terminal=false" | ||
| 689 | (conf-mode-initialize "#" 'conf-desktop-font-lock-keywords) | ||
| 690 | (conf-quote-normal nil)) | ||
| 691 | |||
| 680 | (provide 'conf-mode) | 692 | (provide 'conf-mode) |
| 681 | 693 | ||
| 682 | ;;; conf-mode.el ends here | 694 | ;;; conf-mode.el ends here |