mirror of
https://github.com/vale981/boon
synced 2025-03-04 17:11:40 -05:00
improve selection with spaces
This commit is contained in:
parent
9604996c14
commit
3363f17f0e
2 changed files with 16 additions and 14 deletions
|
@ -111,7 +111,7 @@ This function is meant to be called interactively."
|
|||
(defun boon-select-with-spaces (regs)
|
||||
"Return the regions REGS, including some surrounding spaces.
|
||||
This function is meant to be called interactively."
|
||||
(interactive (list (boon-spec-region "select contents")))
|
||||
(interactive (list (boon-spec-region "select with spaces")))
|
||||
(cons 'region (mapcar (lambda (reg) (boon-include-surround-spaces reg)) (mapcar 'boon-normalize-reg regs))))
|
||||
|
||||
(defun boon-select-content (regs)
|
||||
|
|
28
boon-regs.el
28
boon-regs.el
|
@ -31,21 +31,23 @@ The size of the borders is HOW-MUCH."
|
|||
(list (boon-mk-reg (boon-reg-end reg) (- (boon-reg-end reg) how-much))
|
||||
(boon-mk-reg (boon-reg-begin reg) (+ (boon-reg-begin reg) how-much))))
|
||||
|
||||
;; TODO: also include surrounding blank lines if the other boundary is at bol/eol.
|
||||
(defun boon-include-surround-spaces (reg)
|
||||
"Extend REG to include spaces after its 'boon-reg-point' (or before, if the region is backwards)."
|
||||
(save-excursion
|
||||
(let* ((beg (boon-reg-begin reg))
|
||||
(end (boon-reg-end reg))
|
||||
(space-at-end (progn
|
||||
(goto-char end)
|
||||
(looking-at "\\s-"))))
|
||||
(if space-at-end
|
||||
(boon-mk-reg beg (progn
|
||||
(skip-syntax-forward "-")
|
||||
(point)))
|
||||
(boon-mk-reg (progn (goto-char beg)
|
||||
(skip-syntax-backward "-")
|
||||
(point))
|
||||
end)))))
|
||||
(let* ((mk (boon-reg-mark reg))
|
||||
(pt (boon-reg-point reg))
|
||||
(fwd (> pt mk)))
|
||||
(boon-mk-reg mk
|
||||
(if fwd
|
||||
(progn
|
||||
(goto-char pt)
|
||||
(skip-syntax-forward "-")
|
||||
(point))
|
||||
(progn
|
||||
(goto-char pt)
|
||||
(skip-syntax-backward "-")
|
||||
(point)))))))
|
||||
|
||||
(defun boon-reg-begin (reg)
|
||||
"The begining of region REG."
|
||||
|
|
Loading…
Add table
Reference in a new issue