]> code.delx.au - gnu-emacs-elpa/commitdiff
Only hide prefix if something is written after it
authorArtur Malabarba <bruce.connor.am@gmail.com>
Tue, 11 Aug 2015 11:02:19 +0000 (12:02 +0100)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Tue, 11 Aug 2015 11:02:19 +0000 (12:02 +0100)
README.org
nameless.el

index f9c3fa0734cb91aa1d9d0dff7265d873ff75fa5e..1da80511a916918638050b9275110f5072509170 100644 (file)
@@ -16,8 +16,10 @@ To use this package add the following configuration to your Emacs init file.
 (add-hook 'emacs-lisp-mode-hook #'nameless-mode)
 #+END_SRC
 
-You can configure a string to use instead of ~:~ by setting the ~nameless-prefix~,
-and the name of the face used is ~nameless-face~.
+You can configure a string to use instead of ~:~ by setting the
+~nameless-prefix~, and the name of the face used is ~nameless-face~.
+You can even just hide the prefix completely by setting this variable
+to an empty string.
 
 While the mode is active, the =_= key inserts the package namespace if
 appropriate.
index cdc841a365171b359e30ca0219935756a8d3acf3..04f5a40b5b63f8bedd997c273f708b7df94e16a1 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author: Artur Malabarba <emacs@endlessparentheses.com>
 ;; Keywords: convenience, lisp
-;; Version: 0.1
+;; Version: 0.2
 ;; Package-Requires: ((emacs "24.2"))
 
 ;; This program is free software; you can redistribute it and/or modify
@@ -59,9 +59,9 @@
 (defun nameless--compose-as (display)
   "Compose the matched region and return a face spec."
   (when nameless-mode
-    (compose-region (match-beginning 0)
-                    (match-end 0)
-                    (or display nameless-prefix))
+    (compose-region (match-beginning 1)
+                    (match-end 1)
+                    (concat display nameless-prefix))
     '(face nameless-face)))
 
 (defvar-local nameless--font-lock-keywords nil)
@@ -84,7 +84,7 @@
               (cons 'composition font-lock-extra-managed-props))
   (let ((kws nil))
     (while r
-      (push `(,(pop r) 0 (nameless--compose-as ,(pop r)) prepend) kws))
+      (push `(,(pop r) 1 (nameless--compose-as ,(pop r)) prepend) kws))
     (setq nameless--font-lock-keywords kws)
     (font-lock-add-keywords nil kws t))
   (nameless--ensure))
 
 (defun nameless--name-regexp (name)
   "Return a regexp of the current name."
-  (concat "\\<" (regexp-quote name) "-"))
+  (concat "\\<\\(" (regexp-quote name) "-\\)\\(\\s_\\|\\sw\\)"))
 
 \f
 ;;; Minor mode