winterTTr / ace-jump-mode

a quick cursor jump mode for emacs
https://github.com/winterTTr/ace-jump-mode/wiki
605 stars 72 forks source link

Two chars ace-jump mode #23

Open maio opened 11 years ago

maio commented 11 years ago

Hi,

few days ago I came across vim-seek http://www.vim.org/scripts/script.php?script_id=4416 and I thought it would be nice to have something similar in ace-jump especially for char mode which often displays too many jump markers. So I created modified ace-jump-char-mode which takes 2 characters instead of one. It works really and it seems that it would replace both char and word mode for me. Would you be in favor of including such functionality into ace-jump?

(defun ace-jump-two-chars-mode (query-char query-char-2)
  "AceJump two chars mode"
  (interactive (list (read-char "First Char:")
                     (read-char "Second:")))

  (if (eq (ace-jump-char-category query-char) 'other)
    (error "[AceJump] Non-printable character"))

  ;; others : digit , alpha, punc
  (setq ace-jump-query-char query-char)
  (setq ace-jump-current-mode 'ace-jump-char-mode)
  (ace-jump-do (regexp-quote (concat (char-to-string query-char)
                                     (char-to-string query-char-2)))))
maxhgerlach commented 10 years ago

Nice, for now I've bound this to C-l SPC.

joca-bt commented 10 years ago

That would be awesome, as this been merged?

mlsteele commented 9 years ago

Sometimes I like to seek for just 1 character by pressing enter after just 1 character. I tweaked the function to allow for that.

(defun ace-jump-two-chars-mode (query-char query-char-2)
  "AceJump two chars mode"
  (interactive (list (read-char "First Char:")
                     (read-char "Second:")))

  (if (eq (ace-jump-char-category query-char) 'other)
    (error "[AceJump] Non-printable character"))

  ;; others : digit , alpha, punc
  (let ((query-string (cond ((eq query-char-2 ?\r)
                 (format "%c" query-char))
                (t
                 (format "%c%c" query-char query-char-2)))))
    (setq ace-jump-query-char query-char)
    (setq ace-jump-current-mode 'ace-jump-char-mode)
    (ace-jump-do (regexp-quote query-string))))