]> code.delx.au - gnu-emacs-elpa/commitdiff
[Fix #12] Hack-local-variables
authorArtur Malabarba <bruce.connor.am@gmail.com>
Mon, 28 Mar 2016 23:59:23 +0000 (20:59 -0300)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Mon, 28 Mar 2016 23:59:23 +0000 (20:59 -0300)
README.org
nameless.el

index 9d8b7eb5e906134b60b707729657ecc3d7f69426..46b861b4b415c019e9c503fa53ccf4375955ece4 100644 (file)
@@ -14,7 +14,7 @@ the *right* has ~nameless-mode~ turned on.\\
 To use this package add the following configuration to your Emacs init file.
 
 #+BEGIN_SRC emacs-lisp
-(add-hook 'emacs-lisp-mode-hook #'nameless-mode-from-hook)
+(add-hook 'emacs-lisp-mode-hook #'nameless-mode)
 #+END_SRC
 
 You can configure a string to use instead of ~:~ by setting the
index 183b46d181fcf5741819118581eaa27c8101c155..cf463cd82c51bab662c38eb5c94f3fd4af71ae82 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author: Artur Malabarba <emacs@endlessparentheses.com>
 ;; URL: https://github.com/Malabarba/nameless
 ;; Keywords: convenience, lisp
-;; Version: 0.5.1
+;; Version: 1.0.0
 ;; Package-Requires: ((emacs "24.4"))
 
 ;; This program is free software; you can redistribute it and/or modify
@@ -256,6 +256,15 @@ Return S."
     (remove-text-properties 0 length '(composition nil display nil) s)
     s))
 
+(defun nameless--after-hack-local-variables ()
+  "Set font-lock-keywords after `hack-local-variables-hook'."
+  (nameless--remove-keywords)
+  (apply #'nameless--add-keywords
+         `(,@(when nameless-current-name
+               `((nil . ,nameless-current-name)))
+           ,@nameless-global-aliases
+           ,@nameless-aliases)))
+
 \f
 ;;; Minor mode
 ;;;###autoload
@@ -267,25 +276,23 @@ Return S."
                    nameless-discover-current-name
                    (ignore-errors (string-match "\\.el\\'" (lm-get-package-name))))
           (setq nameless-current-name
-                (replace-regexp-in-string "\\(-mode\\)?\\.[^.]*\\'" "" (lm-get-package-name))))
+                (replace-regexp-in-string "\\(-mode\\)?\\(-tests?\\)?\\.[^.]*\\'" "" (lm-get-package-name))))
         (add-function :filter-return (local 'filter-buffer-substring-function)
                       #'nameless--filter-string)
-        (apply #'nameless--add-keywords
-               `(,@(when nameless-current-name
-                     `((nil . ,nameless-current-name)))
-                 ,@nameless-global-aliases
-                 ,@nameless-aliases)))
+        (nameless--after-hack-local-variables)
+        (add-hook 'hack-local-variables-hook
+                  #'nameless--after-hack-local-variables
+                  nil 'local))
     (remove-function (local 'filter-buffer-substring-function)
                      #'nameless--filter-string)
     (setq nameless-current-name nil)
+    (remove-hook 'hack-local-variables-hook
+                 #'nameless--after-hack-local-variables
+                 'local)
     (nameless--remove-keywords)))
 
 ;;;###autoload
-(defun nameless-mode-from-hook ()
-  "Turn on `nameless-mode'.
-Designed to be added to `emacs-lisp-mode-hook'.
-Interactively, just invoke `nameless-mode' directly."
-  (add-hook 'find-file-hook #'nameless-mode nil 'local))
+(define-obsolete-function-alias 'nameless-mode-from-hook 'nameless-mode "1.0.0")
 
 (provide 'nameless)
 ;;; nameless.el ends here