]> code.delx.au - gnu-emacs-elpa/blobdiff - nameless.el
Add url
[gnu-emacs-elpa] / nameless.el
index e971afb0df51dcaf0fc086de59d5bcc0c8e29fab..183b46d181fcf5741819118581eaa27c8101c155 100644 (file)
@@ -3,6 +3,7 @@
 ;; Copyright (C) 2015 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba <emacs@endlessparentheses.com>
+;; URL: https://github.com/Malabarba/nameless
 ;; Keywords: convenience, lisp
 ;; Version: 0.5.1
 ;; Package-Requires: ((emacs "24.4"))
@@ -112,6 +113,17 @@ For instance, the function `foobar--internal-impl' will be
 displayed as `::internal-impl', instead of `:-internal-impl'."
   :type 'boolean)
 
+(defcustom nameless-separator "-"
+  "Separator used between package prefix and rest of symbol.
+The separator is hidden along with the package name.  For
+instance, setting it to \"/\" means that `init/bio' will be
+displayed as `:bio' (assuming `nameless-current-name' is
+\"init\").  The default is \"-\", since this is the
+separator recommended by the Elisp manual.
+
+Value can also be nil, in which case the separator is never hidden."
+  :type '(choice string (constant nil)))
+
 \f
 ;;; Font-locking
 (defun nameless--make-composition (s)
@@ -132,7 +144,7 @@ displayed as `::internal-impl', instead of `:-internal-impl'."
           (beg (match-beginning 1))
           (end (match-end 1))
           (private-prefix (and nameless-private-prefix
-                               (equal "-" (substring (match-string 0) -1)))))
+                               (equal nameless-separator (substring (match-string 0) -1)))))
       (when private-prefix
         (setq beg (match-beginning 0))
         (setq end (match-end 0))
@@ -161,7 +173,7 @@ ALIAS may be nil, in which case it refers to `nameless-current-name'.
 \(fn (alias . display) [(alias . display) ...])"
   (setq-local font-lock-extra-managed-props
               `(composition display ,@font-lock-extra-managed-props))
-  (let ((kws (mapcar (lambda (x) `(,(nameless--name-regexp (cdr x)) 1 (nameless--compose-as ,(car x)))) r)))
+  (let ((kws (mapcar (lambda (x) `(,(nameless--name-regexp (cdr x)) 1 (nameless--compose-as ,(car x)) prepend)) r)))
     (setq nameless--font-lock-keywords kws)
     (font-lock-add-keywords nil kws t))
   (nameless--ensure))
@@ -211,7 +223,7 @@ configured, or if `nameless-current-name' is nil."
           (unless noerror
             (user-error "No name for alias `%s', see `nameless-aliases'" alias))))
     (if nameless-current-name
-        (progn (insert nameless-current-name "-")
+        (progn (insert nameless-current-name nameless-separator)
                t)
       (unless noerror
         (user-error "No name for current buffer, see `nameless-current-name'")))))
@@ -234,7 +246,8 @@ configured, or if `nameless-current-name' is nil."
 
 (defun nameless--name-regexp (name)
   "Return a regexp of the current name."
-  (concat "\\_<@?\\(" (regexp-quote name) "-\\)\\(\\s_\\|\\sw\\)"))
+  (concat "\\_<@?\\(" (regexp-quote name)
+          nameless-separator "\\)\\(\\s_\\|\\sw\\)"))
 
 (defun nameless--filter-string (s)
   "Remove from string S any disply or composition properties.