1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-02-04 20:27:45 +00:00

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.
This commit is contained in:
Mark Oteiza 2017-08-27 22:22:29 -04:00
parent 9e79a31c09
commit 043a84702f
3 changed files with 27 additions and 11 deletions

View File

@ -1128,6 +1128,9 @@ fontification, and commenting for embedded JavaScript and CSS.
** New mode 'conf-toml-mode' is a sub-mode of conf-mode, specialized
for editing TOML files.
** New mode 'conf-desktop-mode' is a sub-mode of conf-unix-mode,
specialized for editing freedesktop.org desktop entries.
** New minor mode 'pixel-scroll-mode' provides smooth pixel-level scrolling.
** New major mode 'less-css-mode' (a minor variant of 'css-mode') for

View File

@ -2611,11 +2611,12 @@ ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|CBR\\|7Z\\)\\'" . archive-mo
("/config\\.\\(?:bat\\|log\\)\\'" . fundamental-mode)
;; Windows candidates may be opened case sensitively on Unix
("\\.\\(?:[iI][nN][iI]\\|[lL][sS][tT]\\|[rR][eE][gG]\\|[sS][yY][sS]\\)\\'" . conf-mode)
("\\.\\(?:desktop\\|la\\)\\'" . conf-unix-mode)
("\\.la\\'" . conf-unix-mode)
("\\.ppd\\'" . conf-ppd-mode)
("java.+\\.conf\\'" . conf-javaprop-mode)
("\\.properties\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . conf-javaprop-mode)
("\\.toml\\'" . conf-toml-mode)
("\\.desktop\\'" . conf-desktop-mode)
("\\`/etc/\\(?:DIR_COLORS\\|ethers\\|.?fstab\\|.*hosts\\|lesskey\\|login\\.?de\\(?:fs\\|vperm\\)\\|magic\\|mtab\\|pam\\.d/.*\\|permissions\\(?:\\.d/.+\\)?\\|protocols\\|rpc\\|services\\)\\'" . conf-space-mode)
("\\`/etc/\\(?:acpid?/.+\\|aliases\\(?:\\.d/.+\\)?\\|default/.+\\|group-?\\|hosts\\..+\\|inittab\\|ksysguarddrc\\|opera6rc\\|passwd-?\\|shadow-?\\|sysconfig/.+\\)\\'" . conf-mode)
;; ChangeLog.old etc. Other change-log-mode entries are above;

View File

@ -262,6 +262,12 @@ This variable is best set in the file local variables, or through
("\\_<false\\|true\\_>" 0 'font-lock-keyword-face))
"Keywords to highlight in Conf TOML mode.")
(defvar conf-desktop-font-lock-keywords
`(,@conf-font-lock-keywords
("\\_<false\\|true\\_>" 0 'font-lock-constant-face)
("\\_<%[uUfFick%]\\_>" 0 'font-lock-constant-face))
"Keywords to highlight in Conf Desktop mode.")
(defvar conf-assignment-sign ?=
"Sign used for assignments (char or string).")
@ -449,16 +455,7 @@ The optional arg FONT-LOCK is the value for FONT-LOCK-KEYWORDS."
;;;###autoload
(define-derived-mode conf-unix-mode conf-mode "Conf[Unix]"
"Conf Mode starter for Unix style Conf files.
Comments start with `#'.
For details see `conf-mode'. Example:
# Conf mode font-locks this right on Unix and with \\[conf-unix-mode]
[Desktop Entry]
Encoding=UTF-8
Name=The GIMP
Name[ca]=El GIMP
Name[cs]=GIMP"
Comments start with `#'. For details see `conf-mode'."
(conf-mode-initialize "#"))
;;;###autoload
@ -677,6 +674,21 @@ value = \"some string\""
(setq-local conf-assignment-column 0)
(setq-local conf-assignment-sign ?=))
;;;###autoload
(define-derived-mode conf-desktop-mode conf-unix-mode "Conf[Desktop]"
"Conf Mode started for freedesktop.org Desktop files.
Comments start with `#' and \"assignments\" are with `='.
For details see `conf-mode'.
# Conf mode font-locks this correctly with \\[conf-desktop-mode]
[Desktop Entry]
Name=GNU Image Manipulation Program
Name[oc]=Editor d'imatge GIMP
Exec=gimp-2.8 %U
Terminal=false"
(conf-mode-initialize "#" 'conf-desktop-font-lock-keywords)
(conf-quote-normal nil))
(provide 'conf-mode)
;;; conf-mode.el ends here