[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master adc0d66 06/39: Use safe version of propertize
From: |
Justin Burkett |
Subject: |
[elpa] master adc0d66 06/39: Use safe version of propertize |
Date: |
Thu, 21 Jun 2018 15:48:13 -0400 (EDT) |
branch: master
commit adc0d660ad495289042dd77bab1e9ca59b63e555
Author: Justin Burkett <address@hidden>
Commit: Justin Burkett <address@hidden>
Use safe version of propertize
Should fix #186
---
which-key.el | 44 +++++++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/which-key.el b/which-key.el
index ae69371..ea4767d 100644
--- a/which-key.el
+++ b/which-key.el
@@ -1492,12 +1492,17 @@ no title exists."
which-key--current-show-keymap-name)
(t "")))
+(defun which-key--propertize (string &rest properties)
+ "Version of `propertize' that checks type of STRING."
+ (when (stringp string)
+ (apply #'propertize string properties)))
+
(defun which-key--propertize-key (key)
"Add a face to KEY.
If KEY contains any \"special keys\" defined in
`which-key-special-keys' then truncate and add the corresponding
`which-key-special-key-face'."
- (let ((key-w-face (propertize key 'face 'which-key-key-face))
+ (let ((key-w-face (which-key--propertize key 'face 'which-key-key-face))
(regexp (concat "\\("
(mapconcat 'identity which-key-special-keys
"\\|") "\\)"))
@@ -1507,7 +1512,7 @@ If KEY contains any \"special keys\" defined in
(string-match regexp key))
(let ((beg (match-beginning 0)) (end (match-end 0)))
(concat (substring key-w-face 0 beg)
- (propertize (substring key-w-face beg (1+ beg))
+ (which-key--propertize (substring key-w-face beg (1+ beg))
'face 'which-key-special-key-face)
(substring key-w-face end
(which-key--string-width key-w-face))))
@@ -1516,7 +1521,7 @@ If KEY contains any \"special keys\" defined in
(defsubst which-key--truncate-description (desc)
"Truncate DESC description to `which-key-max-description-length'."
(let* ((last-face (get-text-property (1- (length desc)) 'face desc))
- (dots (propertize ".." 'face last-face)))
+ (dots (which-key--propertize ".." 'face last-face)))
(if (and which-key-max-description-length
(> (length desc) which-key-max-description-length))
(concat (substring desc 0 which-key-max-description-length) dots)
@@ -1594,8 +1599,8 @@ return the docstring."
(doc (when (commandp orig-sym)
(documentation orig-sym)))
(docstring (when doc
- (propertize (car (split-string doc "\n"))
- 'face 'which-key-docstring-face))))
+ (which-key--propertize (car (split-string doc "\n"))
+ 'face
'which-key-docstring-face))))
(cond ((not (and which-key-show-docstrings docstring))
current)
((eq which-key-show-docstrings 'docstring-only)
@@ -1608,7 +1613,8 @@ return the docstring."
faces and perform replacements according to the three replacement
alists. Returns a list (key separator description)."
(let ((sep-w-face
- (propertize which-key-separator 'face 'which-key-separator-face))
+ (which-key--propertize which-key-separator
+ 'face 'which-key-separator-face))
(local-map (current-local-map))
new-list)
(dolist (key-binding unformatted)
@@ -1911,8 +1917,8 @@ is the width of the live window."
(or which-key--using-show-operator-keymap
(not (and which-key-allow-evil-operators
(bound-and-true-p evil-this-operator)))))
- (propertize (format "[%s paging/help]" key)
- 'face 'which-key-note-face))))
+ (which-key--propertize (format "[%s paging/help]" key)
+ 'face 'which-key-note-face))))
(eval-and-compile
(if (fboundp 'universal-argument--description)
@@ -1947,7 +1953,7 @@ including prefix arguments."
(if (or (eq which-key-show-prefix 'echo) dont-prop-keys)
(concat str dash)
(concat (which-key--propertize-key str)
- (propertize dash 'face 'which-key-key-face)))))
+ (which-key--propertize dash 'face 'which-key-key-face)))))
(defun which-key--get-popup-map ()
"Generate transient-map for use in the top level binding display."
@@ -1971,17 +1977,17 @@ and a page count."
(nxt-pg-hint (which-key--next-page-hint prefix-keys))
;; not used in left case
(status-line
- (concat (propertize (which-key--maybe-get-prefix-title
- (which-key--current-key-string))
- 'face 'which-key-note-face)
+ (concat (which-key--propertize (which-key--maybe-get-prefix-title
+ (which-key--current-key-string))
+ 'face 'which-key-note-face)
(when (< 1 n-pages)
- (propertize (format " (%s of %s)"
- (1+ page-n) n-pages)
- 'face 'which-key-note-face)))))
+ (which-key--propertize (format " (%s of %s)"
+ (1+ page-n) n-pages)
+ 'face 'which-key-note-face)))))
(pcase which-key-show-prefix
(`left
- (let* ((page-cnt (propertize (format "%s/%s" (1+ page-n) n-pages)
- 'face 'which-key-separator-face))
+ (let* ((page-cnt (which-key--propertize (format "%s/%s" (1+ page-n)
n-pages)
+ 'face
'which-key-separator-face))
(first-col-width (+ 2 (max (which-key--string-width full-prefix)
(which-key--string-width page-cnt))))
(prefix (format (concat "%-" (int-to-string first-col-width) "s")
@@ -2207,13 +2213,13 @@ prefix) if `which-key-use-C-h-commands' is non nil."
(let* ((prefix-keys (key-description which-key--current-prefix))
(full-prefix (which-key--full-prefix prefix-keys current-prefix-arg
t))
(prompt (concat (when (string-equal prefix-keys "")
- (propertize
+ (which-key--propertize
(concat " "
(or which-key--current-show-keymap-name
"Top-level bindings"))
'face 'which-key-note-face))
full-prefix
- (propertize
+ (which-key--propertize
(substitute-command-keys
(concat
" \\<which-key-C-h-map>"
- [elpa] master e5db4b6 07/39: Handle null description in which-key--propertize-description, (continued)
- [elpa] master e5db4b6 07/39: Handle null description in which-key--propertize-description, Justin Burkett, 2018/06/21
- [elpa] master 0aae4c8 04/39: Improve which-key-show-docstrings option, Justin Burkett, 2018/06/21
- [elpa] master 6a4d2c2 09/39: Extract which-key--ignore-keys-regexp and which-key-show-keymap-1, Justin Burkett, 2018/06/21
- [elpa] master ca991b0 11/39: Autoload the show keymap functions, Justin Burkett, 2018/06/21
- [elpa] master fd714bc 13/39: Fix docstring of which-key--get-keymap-bindings, Justin Burkett, 2018/06/21
- [elpa] master b5f7063 15/39: Detect menu-items in which-key--get-keymap-bindings, Justin Burkett, 2018/06/21
- [elpa] master 5493d22 05/39: Fix description truncation when showing docstrings, Justin Burkett, 2018/06/21
- [elpa] master 2e53187 14/39: Fix typo in previous commit, Justin Burkett, 2018/06/21
- [elpa] master 7da9f8c 16/39: Fix which-key--show-keymap when no bidnings found, Justin Burkett, 2018/06/21
- [elpa] master 3c05294 26/39: Fix which-key--create-pages, Justin Burkett, 2018/06/21
- [elpa] master adc0d66 06/39: Use safe version of propertize,
Justin Burkett <=
- [elpa] master 0f80d0f 17/39: Use symbol at point in whow keymap functions, Justin Burkett, 2018/06/21
- [elpa] master 61e399f 22/39: Add and use which-key--automatic-display, Justin Burkett, 2018/06/21
- [elpa] master 506c348 10/39: Add which-key-show-full-keymap, Justin Burkett, 2018/06/21
- [elpa] master d19fe4e 30/39: Fix switching to top-level from which-key-undo-key, Justin Burkett, 2018/06/21
- [elpa] master 9dc8d32 20/39: Add which-key-toggle-docstrings, Justin Burkett, 2018/06/21
- [elpa] master 206be7a 33/39: Fix behavior of f and t in evil operator map, Justin Burkett, 2018/06/21
- [elpa] master e97253b 24/39: Add prefix arg to which-key--get-current-bindings and .., Justin Burkett, 2018/06/21
- [elpa] master ded908e 25/39: Remove which-key--current-prefix, Justin Burkett, 2018/06/21
- [elpa] master 013681a 28/39: Fixes related to removal of which-key--current-prefix, Justin Burkett, 2018/06/21
- [elpa] master ff79dff 38/39: Version 3.3.0, Justin Burkett, 2018/06/21