[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master eba0fdd 1/7: [Fix #2] Add option to display internal symbo
From: |
Artur Malabarba |
Subject: |
[elpa] master eba0fdd 1/7: [Fix #2] Add option to display internal symbols with the prefix |
Date: |
Sun, 13 Sep 2015 15:01:10 +0000 |
branch: master
commit eba0fdd7e63844ff18c1eba760eab1b1376e27db
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>
[Fix #2] Add option to display internal symbols with the prefix
---
README.org | 11 +++++++++++
nameless.el | 21 ++++++++++++++++++---
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/README.org b/README.org
index 367ffed..49ea800 100644
--- a/README.org
+++ b/README.org
@@ -78,6 +78,17 @@ as a file-local variable.
Note that there’s no ~quote~ before ~((c~!\\
You can also configure it for a whole project, by setting it as a dir-local
variable.
+** Private symbols
+
+Private symbols in elisp are written with an extra dash after the
+prefix (e.g., ~foobar--indent-impl~). With Nameless, these are usually
+displayed as ~:-indent-impl~, but you can also make them be displayed
+as ~::indent-impl~ by setting
+
+#+BEGIN_SRC emacs-lisp
+(setq nameless-private-prefix t)
+#+END_SRC
+
** 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
diff --git a/nameless.el b/nameless.el
index f7b47ef..3d7f7b9 100644
--- a/nameless.el
+++ b/nameless.el
@@ -98,6 +98,12 @@ for it to take effect."
(const :tag "Don't affect indentation" nil)
(const :tag "Only outside strings" 'outside-strings)))
+(defcustom nameless-private-prefix nil
+ "If non-nil, private symbols are displayed with a double prefix.
+For instance, the function `foobar--internal-impl' will be
+displayed as `::internal-impl', instead of `:-internal-impl'."
+ :type 'boolean)
+
;;; Font-locking
(defun nameless--make-composition (s)
@@ -116,9 +122,14 @@ for it to take effect."
(not (nth 3 (syntax-ppss)))))))
(dis (concat display nameless-prefix)))
(when compose
- (compose-region (match-beginning 1)
- (match-end 1)
- (nameless--make-composition dis)))
+ (if (and nameless-private-prefix
+ (equal "-" (substring (match-string 0) -1)))
+ (compose-region (match-beginning 0)
+ (match-end 0)
+ (nameless--make-composition (concat dis
nameless-prefix)))
+ (compose-region (match-beginning 1)
+ (match-end 1)
+ (nameless--make-composition dis))))
`(face nameless-face ,@(unless compose (list 'display dis))))))
(defvar-local nameless--font-lock-keywords nil)
@@ -210,6 +221,10 @@ configured, or if `nameless-current-name' is nil."
"Return a regexp of the current name."
(concat "\\_<@?\\(" (regexp-quote name) "-\\)\\(\\s_\\|\\sw\\)"))
+(defun nameless--private-name-regexp (name)
+ "Return a regexp of the current private name."
+ (concat "\\_<@?\\(" (regexp-quote name) "--\\)\\(\\s_\\|\\sw\\)"))
+
(defun nameless--filter-string (s)
"Remove from string S any disply or composition properties.
Return S."
- [elpa] master updated (ad82b99 -> 11dbed7), Artur Malabarba, 2015/09/13
- [elpa] master eba0fdd 1/7: [Fix #2] Add option to display internal symbols with the prefix,
Artur Malabarba <=
- [elpa] master 663f78a 2/7: [Fix #8] Add undo-boundaries before inserting the prefix, Artur Malabarba, 2015/09/13
- [elpa] master 121a841 4/7: Fix private prefixes with the `display' method, Artur Malabarba, 2015/09/13
- [elpa] master b9fd4d7 3/7: Fix typo that completely broke everything, Artur Malabarba, 2015/09/13
- [elpa] master 4ce354f 5/7: Doc, Artur Malabarba, 2015/09/13
- [elpa] master 29bfd87 6/7: Version bump, Artur Malabarba, 2015/09/13
- [elpa] master 11dbed7 7/7: Merge commit '29bfd8704b99f0b8600ea2bdc1f467df04c9e8bc', Artur Malabarba, 2015/09/13