;;; ll-char --- luki char -*- lexical-binding: t -*- ;; ;;; Commentary: ;; ;;; Code: (require 'cl-lib) (cl-pushnew "." load-path :test #'string=) (require 'll) (require 'll-type) (require 'll-list) (defun ll-put-char-face (pos prop) (when-let* ((p prop) (beg (max pos (point-min))) (end (min (1+ pos) (point-max)))) (put-text-property beg end 'face p))) (defun ll-delete-char (&optional n not-eol) (or (ni n) (setf n 1)) (when-let* ((beg (unless (& not-eol (= (point) (pos-eol))) (point))) (end (min (point-max) (+ beg n))) (n (- end beg))) (delete-char n))) (defun what-char (&optional pos) (i) (or pos (setf pos (point))) (if-let* ((chr (char-after pos)) (new (get-char-code-property chr 'name)) (old (get-char-code-property chr 'old-name)) (msg (downcase (if (& new old) (@f "%s [old name: %s]" new old) (or new old))))) (progn (kill-new msg) ($ msg)) ($ "no char!"))) ;; (what-char) ; space ;; (what-char)} ; right curly bracket (old name closing curly bracket) ;; M-x what-char RET ; line feed (lf) (defun alphabet (&optional as-list) (let ((abc "a b c d e f g h i j k l m n o p q r s t u v w x y z")) (if as-list (cl-remove ?\s (string-to-list abc)) abc))) ;; (alphabet) ; a b c d e f g h i j k l m n o p q r s t u v w x y z ;; (alphabet 'as-list) ; (97 98 99 100 101 102 103 104 105 106 107 108 ...) ;; (--- (alphabet 'as-list)) ; 26 (defun echo-alphabet (&optional num) (interactive "P") (let ((as-list (alphabet 'as-list))) (or num (setq num (--- as-list))) (let* ((part (cl-subseq as-list 0 num)) (str-list (mapcar (L (c) (char-to-string c)) part)) (str-almost (@f "%s" str-list)) (str (substring str-almost 1 (1- (--- str-almost))))) ($ str)))) (defalias 'abc #'echo-alphabet) ;; (echo-alphabet 2) ; a b ;; (echo-alphabet -2) ; a b c d e f g h i j k l m n o p q r s t u v w x ;; (echo-alphabet 10) ; a b c d e f g h i j ;; (echo-alphabet -10) ; a b c d e f g h i j k l m n o p (provide 'll-char) ;;; ll-char.el ends here