Skip to content

Commit

Permalink
Remove an argument for regexp for highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsunenobu Kai committed Feb 18, 2014
1 parent 47e034e commit 2c2d031
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions guide-key.el
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ positive, otherwise disable."
"Popup function called after delay of `guide-key/idle-delay' second."
(let ((key-seq (this-command-keys-vector)))
(let ((dsc-buf (current-buffer))
(hi-regexp guide-key/highlight-command-regexp)
(max-width 0))
(with-current-buffer (get-buffer-create guide-key/guide-buffer-name)
(unless truncate-lines (setq truncate-lines t)) ; don't fold line
Expand All @@ -336,7 +335,7 @@ positive, otherwise disable."
(text-scale-set guide-key/text-scale-amount)
(erase-buffer)
(describe-buffer-bindings dsc-buf key-seq)
(when (> (guide-key/format-guide-buffer key-seq hi-regexp) 0)
(when (> (guide-key/format-guide-buffer key-seq) 0)
(guide-key/close-guide-buffer)
(guide-key/popup-guide-buffer))))))

Expand Down Expand Up @@ -447,7 +446,7 @@ For example, both \"C-x r\" and \"\\C-xr\" are converted to [24 114]"
(cancel-timer guide-key/polling-timer)
(setq guide-key/polling-timer nil))

(defun guide-key/format-guide-buffer (key-seq hi-regexp)
(defun guide-key/format-guide-buffer (key-seq)
"Format guide buffer. This function returns the number of following keys."
(let ((fkey-list nil) ; list of (following-key space command)
(fkey-str-list nil) ; fontified string of `fkey-list'
Expand All @@ -465,7 +464,7 @@ For example, both \"C-x r\" and \"\\C-xr\" are converted to [24 114]"
;; fontify following keys as string
(setq fkey-str-list
(loop for (key space command) in fkey-list
collect (guide-key/fontified-string key space command hi-regexp)))
collect (guide-key/fontified-string key space command)))
;; insert a few following keys per line
(guide-key/insert-following-key fkey-str-list
(popwin:position-horizontal-p guide-key/popup-window-position))
Expand All @@ -492,20 +491,20 @@ is popped up at left or right."
do (insert fkey-str (if (= (mod column columns) 0) "\n" " ")))
(align-regexp (point-min) (point-max) "\\(\\s-*\\) \\[" 1 1 t)))

(defun guide-key/fontified-string (key space command hi-regexp)
(defun guide-key/fontified-string (key space command)
"Return fontified string of following key"
(concat (propertize "[" 'face 'guide-key/key-face)
(guide-key/propertize-string-according-to-command key command hi-regexp)
(guide-key/propertize-string-according-to-command key command)
(propertize "]" 'face 'guide-key/key-face)
(if guide-key/align-command-by-space-flag space " ") ; white space
(guide-key/propertize-string-according-to-command command command hi-regexp)))
(guide-key/propertize-string-according-to-command command command)))

(defun guide-key/propertize-string-according-to-command (string command hi-regexp)
(defun guide-key/propertize-string-according-to-command (string command)
"Return STRING putted text property accordinig to COMMAND"
(cond ((string-match guide-key/highlight-prefix-regexp command)
(propertize string 'face 'guide-key/prefix-command-face))
((and (not (string= hi-regexp ""))
(string-match hi-regexp command))
((and (not (string= guide-key/highlight-command-regexp ""))
(string-match guide-key/highlight-command-regexp command))
(propertize string 'face 'guide-key/highlight-command-face))
(t
string)))
Expand Down

0 comments on commit 2c2d031

Please sign in to comment.