[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 043a847: Font-lock FDO desktop files correctly
From: |
Mark Oteiza |
Subject: |
[Emacs-diffs] master 043a847: Font-lock FDO desktop files correctly |
Date: |
Sun, 27 Aug 2017 22:41:45 -0400 (EDT) |
branch: master
commit 043a84702f3002d711784e5fe97c9ea8690b4cfa
Author: Mark Oteiza <address@hidden>
Commit: Mark Oteiza <address@hidden>
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.
---
etc/NEWS | 3 +++
lisp/files.el | 3 ++-
lisp/textmodes/conf-mode.el | 32 ++++++++++++++++++++++----------
3 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 6cd4bca..e8d6ea9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
diff --git a/lisp/files.el b/lisp/files.el
index 872fc46..b3eab29 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -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;
diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el
index b420aaa..d03ee5e 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
("\\_<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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 043a847: Font-lock FDO desktop files correctly,
Mark Oteiza <=