[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 1254161 12/12: Merge commit 'a3dfd7ecf9c58898241c8d1145eb8
From: |
Artur Malabarba |
Subject: |
[elpa] master 1254161 12/12: Merge commit 'a3dfd7ecf9c58898241c8d1145eb8e0c875f5448' |
Date: |
Wed, 14 Oct 2015 11:49:18 +0000 |
branch: master
commit 1254161ead31da9dab50af0ae682c12a1244b338
Merge: 48a3fe4 a3dfd7e
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
Merge commit 'a3dfd7ecf9c58898241c8d1145eb8e0c875f5448'
---
packages/nameless/README.org | 14 ++++++-
packages/nameless/nameless.el | 82 ++++++++++++++++++++++++++---------------
2 files changed, 65 insertions(+), 31 deletions(-)
diff --git a/packages/nameless/README.org b/packages/nameless/README.org
index 49ea800..9d8b7eb 100644
--- a/packages/nameless/README.org
+++ b/packages/nameless/README.org
@@ -53,6 +53,11 @@ M-x add-file-local-variable RET nameless-current-name RET
"package-name"
You can also set the same name for all lisp files in a project by
setting dir-local variables with ~M-x add-file-local-variable~.
+If you /don’t/ want Nameless to use a namespace name at all (neither
+manual nor automatic), you can set ~nameless-discover-current-name~ to
+~nil~. This will disable this functionality, so that Nameless will
+/only/ use aliases (see next item).
+
** Requiring other packages as aliases
Nameless can also be used to “import” other packages as aliases. For
instance, in the default behaviour, functions in the ~font-lock~
@@ -89,10 +94,17 @@ as ~::indent-impl~ by setting
(setq nameless-private-prefix t)
#+END_SRC
+** Packages that don’t use ~-~ (hyphen) as a separator
+You can set ~nameless-separator~ file-locally to whatever separator
+you package uses. Most packages use hyphens, by some use ~/~, ~|~, or
+~:~.
+
+You can also set it to ~nil~ globally and the separator will never be
+hidden.
** Indentation and paragraph filling
Hiding parts of symbols could affect the way Emacs indents your code
and fills your paragraphs. Nameless lets you decide whether you want
-that to happen or not.
+that to happen or not.
The default behavior is that code is indented according to what you
see (i.e., according to short symbols), but text inside strings is
diff --git a/packages/nameless/nameless.el b/packages/nameless/nameless.el
index e79b01e..183b46d 100644
--- a/packages/nameless/nameless.el
+++ b/packages/nameless/nameless.el
@@ -3,8 +3,9 @@
;; Copyright (C) 2015 Free Software Foundation, Inc.
;; Author: Artur Malabarba <address@hidden>
+;; URL: https://github.com/Malabarba/nameless
;; Keywords: convenience, lisp
-;; Version: 0.5
+;; Version: 0.5.1
;; Package-Requires: ((emacs "24.4"))
;; This program is free software; you can redistribute it and/or modify
@@ -82,6 +83,13 @@ variable.")
x)
safe))))
+(defcustom nameless-discover-current-name t
+ "If non-nil, discover package name automatically.
+If nil, `nameless-current-name' must be set explicitly, or left as nil,
+in which case only namespaces from `nameless-global-aliases' and
+`nameless-aliases' are used."
+ :type 'boolean)
+
(defface nameless-face
'((t :inherit font-lock-type-face))
"Face used on `nameless-prefix'")
@@ -96,7 +104,8 @@ After changing this variable, you must reenable
`nameless-mode'
for it to take effect."
:type '(choice (const :tag "Always affect indentation" t)
(const :tag "Don't affect indentation" nil)
- (const :tag "Only outside strings" 'outside-strings)))
+ (const :tag "Only outside strings" outside-strings)))
+(put 'nameless-current-name 'safe-local-variable #'symbolp)
(defcustom nameless-private-prefix nil
"If non-nil, private symbols are displayed with a double prefix.
@@ -104,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)))
+
;;; Font-locking
(defun nameless--make-composition (s)
@@ -120,19 +140,19 @@ displayed as `::internal-impl', instead of
`:-internal-impl'."
(and nameless-affect-indentation-and-filling
(or (not (eq nameless-affect-indentation-and-filling
'outside-strings))
(not (nth 3 (syntax-ppss)))))))
- (dis (concat display nameless-prefix)))
- (when compose
- (if (and nameless-private-prefix
- (equal "-" (substring (match-string 0) -1)))
- (progn
- (setq dis (concat dis nameless-prefix))
- (compose-region (match-beginning 0)
- (match-end 0)
- (nameless--make-composition dis)))
- (compose-region (match-beginning 1)
- (match-end 1)
- (nameless--make-composition dis))))
- `(face nameless-face ,@(unless compose (list 'display dis))))))
+ (dis (concat display nameless-prefix))
+ (beg (match-beginning 1))
+ (end (match-end 1))
+ (private-prefix (and nameless-private-prefix
+ (equal nameless-separator (substring
(match-string 0) -1)))))
+ (when private-prefix
+ (setq beg (match-beginning 0))
+ (setq end (match-end 0))
+ (setq dis (concat dis nameless-prefix)))
+ (if compose
+ (compose-region beg end (nameless--make-composition dis))
+ (add-text-properties beg end (list 'display dis)))
+ '(face nameless-face))))
(defvar-local nameless--font-lock-keywords nil)
@@ -153,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))
@@ -203,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'")))))
@@ -226,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.
@@ -241,18 +262,19 @@ Return S."
(define-minor-mode nameless-mode
nil nil " :" `((,(kbd "C-c C--") . nameless-insert-name))
(if nameless-mode
- (if (or nameless-current-name
- (ignore-errors (string-match "\\.el\\'" (lm-get-package-name))))
- (progn
- (unless nameless-current-name
- (setq nameless-current-name (replace-regexp-in-string
"\\(-mode\\)?\\.[^.]*\\'" "" (lm-get-package-name))))
- (add-function :filter-return (local
'filter-buffer-substring-function)
- #'nameless--filter-string)
- (apply #'nameless--add-keywords
- `((nil . ,nameless-current-name)
- ,@nameless-global-aliases
- ,@nameless-aliases)))
- (nameless-mode -1))
+ (progn
+ (when (and (not nameless-current-name)
+ 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))))
+ (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)))
(remove-function (local 'filter-buffer-substring-function)
#'nameless--filter-string)
(setq nameless-current-name nil)
- [elpa] master d481765 02/12: [Fix #2 again] Private prefixes with the display property, (continued)
- [elpa] master d481765 02/12: [Fix #2 again] Private prefixes with the display property, Artur Malabarba, 2015/10/14
- [elpa] master f2b7501 07/12: Document new features, Artur Malabarba, 2015/10/14
- [elpa] master 005cb1f 01/12: Fix :type for nameless-affect-indentation-and-filling, Artur Malabarba, 2015/10/14
- [elpa] master 7ac7d99 08/12: Prepend the nameless face, Artur Malabarba, 2015/10/14
- [elpa] master a3dfd7e 10/12: Add url, Artur Malabarba, 2015/10/14
- [elpa] master 074c4d8 05/12: Merge pull request #11 from TheBB/optional-current-name, Artur Malabarba, 2015/10/15
- [elpa] master 7252f2e 03/12: Mark nameless-affect-indentation-and-filling as safe local, Artur Malabarba, 2015/10/15
- [elpa] master 40f43e6 04/12: Make discovery of current name optional, Artur Malabarba, 2015/10/15
- [elpa] master 48a3fe4 11/12: Merge commit '9e84a66b07700bebb73592fe320c19794c206ce3', Artur Malabarba, 2015/10/15
- [elpa] master e4087c6 06/12: [Fix #9] Customizable separator, Artur Malabarba, 2015/10/15
- [elpa] master 1254161 12/12: Merge commit 'a3dfd7ecf9c58898241c8d1145eb8e0c875f5448',
Artur Malabarba <=