branch: master
commit c0de8a8ad0f0abbc12bce35fc4a0feebc8892f48
Author: Artur Malabarba <bruce.connor...@gmail.com>
Commit: Artur Malabarba <bruce.connor...@gmail.com>

    [Fix #12] Hack-local-variables
---
 README.org  |    2 +-
 nameless.el |   31 +++++++++++++++++++------------
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/README.org b/README.org
index 9d8b7eb..46b861b 100644
--- a/README.org
+++ b/README.org
@@ -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
diff --git a/nameless.el b/nameless.el
index 183b46d..cf463cd 100644
--- a/nameless.el
+++ b/nameless.el
@@ -5,7 +5,7 @@
 ;; Author: Artur Malabarba <em...@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)))
+
 
 ;;; 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

Reply via email to