Commits

Anonymous committed d820c5e

desktop-entry-mode 0.93 <1073243270.9121.126.camel@bobcat.mine.nu>.

  • Participants
  • Parent commits 967ca8b

Comments (0)

Files changed (2)

+2004-01-04  Ville Skyttä  <scop@xemacs.org>
+
+	* desktop-entry-mode.el: Version 0.93, adding imenu support,
+	better support for X-* keys and group headers, keywords reserved
+	for use with KDE and miscellaneous cosmetic changes.
+
 2003-12-31  Ville Skyttä  <scop@xemacs.org>
 
 	* po-compat.el: Sync with gettext 0.13.1, po-mode.el already in sync.

desktop-entry-mode.el

 ;;; desktop-entry-mode.el --- freedesktop.org desktop entry editing
 
-;; Copyright (C) 2003, Ville Skyttä, <scop at xemacs.org>
+;; Copyright (C) 2003-2004, Ville Skyttä, <scop at xemacs.org>
 
 ;; Author:   Ville Skyttä, <scop at xemacs.org>
 ;; Keywords: unix, desktop entry
 
 ;; This mode provides basic functionality, eg. syntax highlighting and
 ;; validation for freedesktop.org desktop entry files.
+;;
 ;; For more information about desktop entry files, see
-;;   http://www.freedesktop.org/standards/desktop-entry-spec/
+;;   <http://www.freedesktop.org/Standards/desktop-entry-spec>
+;;
+;; This version is up to date with version 0.9.4 of the specification.
 
 ;;; Code:
 
-(defconst desktop-entry-mode-version "0.92")
+(defconst desktop-entry-mode-version "0.93 (spec 0.9.4)"
+  "Version of `desktop-entry-mode'.")
 
 (defgroup desktop-entry nil
   "Support for editing freedesktop.org desktop entry files."
 (defconst desktop-entry-keywords
   (eval-when-compile
     (require 'regexp-opt)
-    (regexp-opt
-     '(
-       "Type"
-       "Version"
-       "Encoding"
-       "Name"
-       "GenericName"
-       "NoDisplay"
-       "Comment"
-       "Icon"
-       "Hidden"
-       "FilePattern"
-       "TryExec"
-       "Exec"
-       "Path"
-       "Terminal"
-       "SwallowTitle"
-       "SwallowExec"
-       "Actions"
-       "MimeType"
-       "SortOrder"
-       "Dev"
-       "FSType"
-       "MountPoint"
-       "ReadOnly"
-       "UnmountIcon"
-       "URL"
-       "Categories"
-       "OnlyShowIn"
-       "NotShowIn"
-       "StartupNotify"
-       "StartupWMClass"
-       ) 'words))
+    (concat
+     "\\(?:"
+     (regexp-opt
+      '(
+        "Type"
+        "Version"
+        "Encoding"
+        "Name"
+        "GenericName"
+        "NoDisplay"
+        "Comment"
+        "Icon"
+        "Hidden"
+        "FilePattern"
+        "TryExec"
+        "Exec"
+        "Path"
+        "Terminal"
+        "SwallowTitle"
+        "SwallowExec"
+        "Actions"
+        "MimeType"
+        "SortOrder"
+        "Dev"
+        "FSType"
+        "MountPoint"
+        "ReadOnly"
+        "UnmountIcon"
+        "URL"
+        "Categories"
+        "OnlyShowIn"
+        "NotShowIn"
+        "StartupNotify"
+        "StartupWMClass"
+        ;; Reserved for use with KDE as of spec 0.9.4.
+        "ServiceTypes"
+        "DocPath"
+        "KeyWords"
+        "InitialPreference"
+        ) 'words)
+     "\\|X-[A-Za-z0-9-]+\\)"))
   "Expression for matching desktop entry keys.")
 
+(defconst desktop-entry-group-header-re
+  "^\\[\\(X-[^\][]+\\|\\(?:Desktop \\(?:Entry\\|Action [a-zA-Z]+\\)\\)\\)\\]"
+  "Regular expression for matching desktop entry group headers.")
+
 (defconst desktop-entry-font-lock-keywords
   (list
    (cons "^\\s-*#.*$" '(0 'font-lock-comment-face))
-   (cons desktop-entry-keywords '(0 'font-lock-keyword-face))
-   (cons "^\\[\\(Desktop \\(Entry\\|Action [a-zA-Z]+\\)\\)\\]"
-         '(1 'desktop-entry-group-header-face))
+   (cons (concat "^" desktop-entry-keywords) '(0 'font-lock-keyword-face))
+   (cons desktop-entry-group-header-re '(1 'desktop-entry-group-header-face))
    (cons "^[A-Za-z0-9-]+?\\s-*=\\s-*\\(.*\\)"
          '(1 'desktop-entry-value-face))
-   (cons "^[A-Za-z0-9-]+?\\[\\(.*\\)\\]\\s-*=\\s-*\\(.*\\)"
+   (cons "^[A-Za-z0-9-]+?\\[\\([^\]]+\\)\\]\\s-*=\\s-*\\(.*\\)"
          '((1 'desktop-entry-locale-face)
            (2 'desktop-entry-value-face)))
    )
   "Highlighting rules for `desktop-entry-mode' buffers.")
 
+(defvar desktop-entry-imenu-generic-expression
+  `((nil ,desktop-entry-group-header-re 1))
+  "Imenu generic expression for `desktop-entry-mode'.
+See `imenu-generic-expression'.")
+
 ;;;###autoload
 (defun desktop-entry-mode ()
   "Major mode for editing freedesktop.org desktop entry files.
-See <http://www.freedesktop.org/standards/desktop-entry-spec/> for more
-information.
+See <http://www.freedesktop.org/Standards/desktop-entry-spec> for more
+information.  See `desktop-entry-mode-version' for information about which
+version of the specification this mode is up to date with.
 
 Turning on desktop entry mode calls the value of the variable
 `desktop-entry-mode-hook' with no args, if that value is non-nil."
   (set (make-local-variable 'comment-end) "")
   (set (make-local-variable 'comment-start-skip) "#+ *")
   (setq major-mode 'desktop-entry-mode mode-name "Desktop Entry")
+  (set (make-local-variable 'imenu-generic-expression)
+       desktop-entry-imenu-generic-expression)
   (run-hooks 'desktop-entry-mode-hook))
 
 (defun desktop-entry-validate ()