emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/helm 5b9ec9b46f 1/2: Add helm-describe-re-char-classes fn


From: ELPA Syncer
Subject: [nongnu] elpa/helm 5b9ec9b46f 1/2: Add helm-describe-re-char-classes fn and use it
Date: Tue, 10 Sep 2024 04:00:48 -0400 (EDT)

branch: elpa/helm
commit 5b9ec9b46f498629ea4b838f5ea4de270de028d3
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>

    Add helm-describe-re-char-classes fn and use it
---
 helm-elisp.el |  6 ++++-
 helm-lib.el   | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+), 1 deletion(-)

diff --git a/helm-elisp.el b/helm-elisp.el
index 0dedda2cbb..1b8d4af66b 100644
--- a/helm-elisp.el
+++ b/helm-elisp.el
@@ -372,7 +372,11 @@ other window according to the value of
       (helm-elisp-show-help "Toggle show help for the symbol")))
 
 (defun helm-elisp--show-help-1 (candidate &optional name)
-  (helm-acase (intern-soft candidate)
+  (helm-acase (if (member candidate helm-lisp-completion-re-chars-classes)
+                  candidate
+                (intern-soft candidate))
+    ((guard (stringp it))
+     (helm-describe-re-char-classes it))
     ((guard (and (fboundp it) (boundp it)))
      (if (member name `(,helm-describe-function-function
                         ,helm-describe-variable-function))
diff --git a/helm-lib.el b/helm-lib.el
index cf088d029c..80712565a9 100644
--- a/helm-lib.el
+++ b/helm-lib.el
@@ -1435,6 +1435,87 @@ If object is a lambda, return \"Anonymous\"."
                          (mapcar 'helm-symbolify faces)
                          (helm-symbolify face))))))
 
+(defun helm-describe-re-char-classes (exp)
+  "Describe Char Classes for regexps."
+  (with-output-to-temp-buffer "*help*"
+    (princ (helm-acase exp
+             (":xdigit:"
+              (format "%s
+This matches the hexadecimal digits:
+‘0’ through ‘9’, ‘a’ through ‘f’ and ‘A’ through ‘F’." it))
+             (":word:"
+              (format "%s
+This matches any character that has word syntax.
+Note that the syntax of a character, and thus which characters are considered
+“word-constituent”, depends on the major mode." it))
+             (":upper:"
+              (format "%s
+This matches any upper-case letter, as determined by the current
+case table.  If ‘case-fold-search’ is non-‘nil’, this also matches
+any lower-case letter.  Note that a buffer can have its own local
+case table different from the default one." it))
+             (":unibyte:"
+              (format "%s
+This matches any unibyte character." it))
+             (":space:"
+              (format "%s
+This matches any character that has whitespace syntax.
+Note that the syntax of a character, and thus
+which characters are considered “whitespace”, depends on the major mode." it))
+             (":punct:"
+              (format "%s
+This matches any punctuation character.  (At present, for multibyte
+characters, it matches anything that has non-word syntax, and thus
+its exact definition can vary from one major mode to another, since
+the syntax of a character depends on the major mode.)" it))
+             (":print:"
+              (format "%s
+This matches any printing character—either spaces or graphic
+characters matched by ‘[:graph:]’." it))
+             (":nonascii:"
+              (format "%s
+This matches any non-ASCII character." it))
+             (":multibyte:"
+              (format "%s
+This matches any multibyte character." it))
+             (":lower:"
+              (format "%s
+This matches any lower-case letter, as determined by the current
+case table.  If ‘case-fold-search’ is non-‘nil’, this also matches
+any upper-case letter.  Note that a buffer can have its own local
+case table different from the default one." it))
+             (":graph:"
+              (format "%s
+This matches graphic characters—everything except spaces, ASCII and
+non-ASCII control characters, surrogates, and codepoints unassigned
+by Unicode, as indicated by the Unicode ‘general-category’ property." it))
+             (":digit:"
+              (format "%s
+This matches ‘0’ through ‘9’.  Thus, ‘[-+[:digit:]]’ matches any
+digit, as well as ‘+’ and ‘-’." it))
+             (":cntrl:"
+              (format "%s
+This matches any character whose code is in the range 0–31." it))
+             (":blank:"
+              (format "%s
+This matches horizontal whitespace, as defined by Annex C of the
+Unicode Technical Standard #18.  In particular, it matches spaces,
+tabs, and other characters whose Unicode ‘general-category’
+property indicates they are spacing separators." it))
+             (":alpha:"
+              (format "%s
+This matches any letter.  For multibyte characters, it matches
+characters whose Unicode ‘general-category’ property indicates
+they are alphabetic characters." it))
+             (":alnum:"
+              (format "%s
+This matches any letter or digit.  For multibyte characters, it
+matches characters whose Unicode ‘general-category’ property
+indicates they are alphabetic or decimal number characters." it))
+             (":ascii:"
+              (format "%s
+This matches any ASCII character (codes 0–127)." it))))))
+
 (defun helm-elisp--persistent-help (candidate fun &optional name)
   "Used to build persistent actions describing CANDIDATE with FUN.
 Argument NAME is used internally to know which command to use



reply via email to

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