Skip to content

Commit

Permalink
feat: Add character section
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Aug 13, 2024
1 parent af16de5 commit 4b33acd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions elenv.el
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,31 @@ For argument REMOTE, see function `executable-find' description."
"Return BUF's function `buffer-file-name' or `buffer-name' respectively."
(or (buffer-file-name buf) (buffer-name buf)))

;;
;;; Character

;;;###autoload
(defun elenv-char-displayable-p (ch)
"Same as function `char-displayable-p' but accept CH as string."
(cond ((stringp ch) (char-displayable-p (string-to-char ch)))
(t (char-displayable-p ch))))

;;;###autoload
(defun elenv-replace-nondisplayable (str &optional rep)
"Replace non-displayable character from STR.
Optional argument REP is the replacement string of non-displayable character."
(if (stringp str)
(let ((rep (or rep ""))
(results (list)))
(dolist (string (split-string str ""))
(let ((string (if (elenv-char-displayable-p string)
string
rep)))
(push string results)))
(string-join (reverse results)))
""))

;;
;;; String

Expand Down

0 comments on commit 4b33acd

Please sign in to comment.