From: Eshel Yaron Date: Sat, 26 Nov 2022 16:18:35 +0000 (+0200) Subject: Add repeat keymap for sweeprolog-forward-hole X-Git-Tag: V9.1.0-sweep-0.9.3~4 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=94dc85fb0f94aaef8f558bb9a0e2794dc770693e;p=sweep.git Add repeat keymap for sweeprolog-forward-hole * sweeprolog.el (sweeprolog-backward-hole): new command. (sweeprolog-forward-hole-repeat-mode): new repeat keymap. --- diff --git a/sweeprolog.el b/sweeprolog.el index ced7f49..3d61d12 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -375,6 +375,14 @@ non-terminals)." map) "Keymap for `sweeprolog-mode'.") +(defvar sweeprolog-forward-hole-repeat-mode + (let ((map (make-sparse-keymap))) + (define-key map (kbd "C-i") #'sweeprolog-forward-hole) + (define-key map (kbd "p") #'sweeprolog-backward-hole) + (define-key map (kbd "n") #'sweeprolog-forward-hole) + map) + "Repeat map for \\[sweeprolog-forward-hole].") + (defvar sweeprolog-top-level-mode-map (let ((map (make-sparse-keymap))) (define-key map (kbd "C-c C-c") #'sweeprolog-top-level-signal-current) @@ -2622,6 +2630,7 @@ point and the beginning of the buffer." (not (eobp))) (forward-char)) (point)))) + (forward-char -1) (while (and (get-text-property (point) 'sweeprolog-hole) (not (bobp))) (forward-char -1)) @@ -2638,7 +2647,7 @@ point and the beginning of the buffer." (while (and (get-text-property (point) 'sweeprolog-hole) (not (bobp))) (forward-char -1)) - (cons (point) end))))) + (cons (1+ (point)) (1+ end)))))) (defun sweeprolog--forward-hole (&optional wrap) (if-let ((hole (sweeprolog--next-hole wrap)) @@ -2658,6 +2667,15 @@ point and the beginning of the buffer." (push-mark beg t t)) (user-error "No holes before point"))) +(defun sweeprolog-backward-hole (&optional arg) + "Move point to the previous hole in a `sweeprolog-mode' buffer. + +With negative prefix argument ARG, move to the next hole +instead." + (interactive "p" sweeprolog-mode) + (setq arg (or arg 1)) + (sweeprolog-forward-hole (- arg))) + (defun sweeprolog-forward-hole (&optional arg) "Move point to the next hole in a `sweeprolog-mode' buffer. @@ -2670,6 +2688,14 @@ instead." (sweeprolog--backward-hole t) (sweeprolog--forward-hole t))) +(put 'sweeprolog-backward-hole + 'repeat-map + 'sweeprolog-forward-hole-repeat-mode) + +(put 'sweeprolog-forward-hole + 'repeat-map + 'sweeprolog-forward-hole-repeat-mode) + (defun sweeprolog--hole (&optional string) (propertize (or string "_") 'sweeprolog-hole t