Skip to content

Commit

Permalink
Use pcase for helm-stringify and use it in helm-elisp
Browse files Browse the repository at this point in the history
  • Loading branch information
thierryvolpiatto committed Jun 29, 2022
1 parent 990c939 commit 213ee16
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions helm-elisp.el
Original file line number Diff line number Diff line change
Expand Up @@ -791,10 +791,7 @@ is only used to test DEFAULT."
(unless (memq 'helm-apropos helm-commands-using-frame)
(setq helm-M-x-show-short-doc (not helm-M-x-show-short-doc)
helm-apropos-show-short-doc (not helm-apropos-show-short-doc))
(helm-update (concat "^" (pcase (helm-get-selection)
((and (pred stringp) str) str)
((and (pred symbolp) sym)
(symbol-name sym))))
(helm-update (concat "^" (helm-stringify (helm-get-selection)))
(helm-get-current-source)))))

;;;###autoload
Expand Down
8 changes: 4 additions & 4 deletions helm-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -1045,10 +1045,10 @@ Examples:
(defun helm-stringify (elm)
"Return the representation of ELM as a string.
ELM can be a string, a number or a symbol."
(cl-typecase elm
(string elm)
(number (number-to-string elm))
(symbol (symbol-name elm))))
(pcase elm
((pred stringp) elm)
((pred numberp) (number-to-string elm))
((pred symbolp) (symbol-name elm))))

(defun helm-substring (str width)
"Return the substring of string STR from 0 to WIDTH.
Expand Down

0 comments on commit 213ee16

Please sign in to comment.