]> code.delx.au - gnu-emacs-elpa/commitdiff
[Fix #2] Add option to display internal symbols with the prefix
authorArtur Malabarba <bruce.connor.am@gmail.com>
Sun, 13 Sep 2015 11:20:11 +0000 (12:20 +0100)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Sun, 13 Sep 2015 11:20:11 +0000 (12:20 +0100)
README.org
nameless.el

index 367ffedaeac055a30d835bf965a52d86287e27dc..49ea800b44c2d05ba7193ada657bee5657e4c67e 100644 (file)
@@ -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
index f7b47efd840d4c3e1cf4dc68bc4c35bdac471504..3d7f7b970ad48114e4b8f53dc8268add4f6ad8e9 100644 (file)
@@ -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)
+
 \f
 ;;; 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."