[Top][All Lists]

[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 
+** 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)
 ** 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 
+          (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."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]