mirror of
https://github.com/vale981/boon
synced 2025-03-05 09:31:43 -05:00
block selector
This commit is contained in:
parent
0e9c4b7ef1
commit
de711094a6
5 changed files with 39 additions and 22 deletions
|
@ -112,6 +112,25 @@ This item is either the symbol at point, or, if this fails, the sexp at point."
|
|||
(save-excursion
|
||||
(boon-jump-over-blanks-forward)
|
||||
(point))))))
|
||||
(defun boon-select-block ()
|
||||
(interactive)
|
||||
(lambda ()
|
||||
(boon-regs-from-bounds
|
||||
(save-excursion
|
||||
(back-to-indentation)
|
||||
(setq temporary-goal-column (current-column))
|
||||
(cons
|
||||
(save-excursion
|
||||
(while (and (not (bolp)) (<= (boon-col-relative-to-indent) 0))
|
||||
(previous-logical-line))
|
||||
(next-logical-line)
|
||||
(beginning-of-line)
|
||||
(point))
|
||||
(save-excursion
|
||||
(while (and (not (bolp)) (<= (boon-col-relative-to-indent) 0))
|
||||
(next-logical-line))
|
||||
(beginning-of-line)
|
||||
(point)))))))
|
||||
|
||||
(defun boon-spec-string-lazy (prompt)
|
||||
"Read a string using the region selection functionality.
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
(define-key boon-select-map "s" 'boon-select-wim) ;; symbol
|
||||
(define-key boon-select-map "t" 'boon-select-with-spaces)
|
||||
(define-key boon-select-map "d" 'boon-select-document)
|
||||
(define-key boon-select-map "b" 'boon-select-block)
|
||||
|
||||
(define-key boon-select-map "C" 'boon-select-comment)
|
||||
(define-key boon-select-map "x" 'boon-select-outside-pairs) ;; eXpression
|
||||
|
|
|
@ -215,7 +215,7 @@ Regions are given by REGS."
|
|||
(defun boon-newline-dwim ()
|
||||
"Insert a new line do-what-i-mean style."
|
||||
(interactive)
|
||||
(if (and (not (eolp)) (string-blank-p (boon-line-prefix)))
|
||||
(if (and (not (eolp)) (< (boon-col-relative-to-indent) 0))
|
||||
(call-interactively 'boon-open-line)
|
||||
(boon-split-line)))
|
||||
|
||||
|
|
|
@ -95,19 +95,21 @@ If possible, prompt the symbol at point."
|
|||
(boon-edge-of-expression nil))
|
||||
|
||||
(defun boon-smarter-upward (count)
|
||||
"Move upward, to a line with the same level of indentation, or less, COUNT times."
|
||||
"Move upward, to a line with the same level of indentation or less, COUNT times."
|
||||
(interactive "p")
|
||||
(back-to-indentation)
|
||||
(dotimes (_number count)
|
||||
(previous-logical-line)
|
||||
(while (boon-at-indent-or-more-p) (previous-logical-line)))
|
||||
(while (< (boon-col-relative-to-indent) 0) (previous-logical-line)))
|
||||
(back-to-indentation))
|
||||
|
||||
(defun boon-smarter-downward (count)
|
||||
"Move downward, to a line with the same level of indentation, or less COUNT times."
|
||||
"Move downward, to a line with the same level of indentation or less, COUNT times."
|
||||
(interactive "p")
|
||||
(back-to-indentation)
|
||||
(dotimes (_number count)
|
||||
(next-logical-line)
|
||||
(while (boon-at-indent-or-more-p) (next-logical-line)))
|
||||
(while (< (boon-col-relative-to-indent) 0) (next-logical-line)))
|
||||
(back-to-indentation))
|
||||
|
||||
(defun boon-smarter-backward (count)
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
(defmacro boon-with-ordered-region (body)
|
||||
"Run the BODY, ensuring that the point is before the mark."
|
||||
(declare (obsolete "Used only by obsolete code" "20160904"))
|
||||
`(if (< (point) (mark))
|
||||
,body
|
||||
(progn (exchange-point-and-mark) ,body (exchange-point-and-mark))))
|
||||
|
@ -28,9 +29,9 @@
|
|||
(back-to-indentation)
|
||||
(current-column)))
|
||||
|
||||
|
||||
(defun boon-line-prefix ()
|
||||
"Return the text between beginning of line and point."
|
||||
(declare (obsolete "use boon-col-relative-to-indent instead" "20160903"))
|
||||
(buffer-substring-no-properties
|
||||
(line-beginning-position)
|
||||
(point)))
|
||||
|
@ -41,15 +42,10 @@
|
|||
(line-end-position)
|
||||
(point)))
|
||||
|
||||
(defun boon-at-indent-or-more-p ()
|
||||
"Return non-nil if the point is at the current line indentation; or to the right."
|
||||
(or (eolp)
|
||||
(and (not (boon-at-indent-p))
|
||||
(string-blank-p (boon-line-prefix)))))
|
||||
|
||||
(defun boon-at-indent-p ()
|
||||
"Return non-nil if the point is at the current line indentation."
|
||||
(eq (save-excursion (back-to-indentation) (point)) (point)))
|
||||
(defun boon-col-relative-to-indent ()
|
||||
"Return the position of the cursor relative to indentation.
|
||||
Can be negative."
|
||||
(- (point) (save-excursion (back-to-indentation) (point))))
|
||||
|
||||
(defun boon-looking-at-comment (how-many)
|
||||
"Is the current point looking at HOW-MANY comments? (negative for backwards)?"
|
||||
|
@ -77,7 +73,6 @@ If no such text exists, throw an error."
|
|||
(or (thing-at-point 'symbol)
|
||||
(error "Nothing relevant at point; move to a symbol or select a region"))))
|
||||
|
||||
|
||||
(defun boon-jump-over-blanks-forward ()
|
||||
"Jump over blanks, forward."
|
||||
(interactive)
|
||||
|
|
Loading…
Add table
Reference in a new issue