|
|
|
@ -453,5 +453,66 @@ Doesn't mess with special buffers." |
|
|
|
(prelude-recompile-init) |
|
|
|
(message "Update finished. Restart Emacs to complete the process."))) |
|
|
|
|
|
|
|
(defun thing-at-point-goto-end-of-integer () |
|
|
|
"Go to end of integer at point." |
|
|
|
(let ((inhibit-changing-match-data t)) |
|
|
|
;; Skip over optional sign |
|
|
|
(when (looking-at "[+-]") |
|
|
|
(forward-char 1)) |
|
|
|
;; Skip over digits |
|
|
|
(skip-chars-forward "[[:digit:]]") |
|
|
|
;; Check for at least one digit |
|
|
|
(unless (looking-back "[[:digit:]]") |
|
|
|
(error "No integer here")))) |
|
|
|
(put 'integer 'beginning-op 'thing-at-point-goto-end-of-integer) |
|
|
|
|
|
|
|
(defun thing-at-point-goto-beginning-of-integer () |
|
|
|
"Go to end of integer at point." |
|
|
|
(let ((inhibit-changing-match-data t)) |
|
|
|
;; Skip backward over digits |
|
|
|
(skip-chars-backward "[[:digit:]]") |
|
|
|
;; Check for digits and optional sign |
|
|
|
(unless (looking-at "[+-]?[[:digit:]]") |
|
|
|
(error "No integer here")) |
|
|
|
;; Skip backward over optional sign |
|
|
|
(when (looking-back "[+-]") |
|
|
|
(backward-char 1)))) |
|
|
|
(put 'integer 'beginning-op 'thing-at-point-goto-beginning-of-integer) |
|
|
|
|
|
|
|
(defun thing-at-point-bounds-of-integer-at-point () |
|
|
|
"Get boundaries of integer at point." |
|
|
|
(save-excursion |
|
|
|
(let (beg end) |
|
|
|
(thing-at-point-goto-beginning-of-integer) |
|
|
|
(setq beg (point)) |
|
|
|
(thing-at-point-goto-end-of-integer) |
|
|
|
(setq end (point)) |
|
|
|
(cons beg end)))) |
|
|
|
(put 'integer 'bounds-of-thing-at-point 'thing-at-point-bounds-of-integer-at-point) |
|
|
|
|
|
|
|
(defun thing-at-point-integer-at-point () |
|
|
|
"Get integer at point." |
|
|
|
(let ((bounds (bounds-of-thing-at-point 'integer))) |
|
|
|
(string-to-number (buffer-substring (car bounds) (cdr bounds))))) |
|
|
|
(put 'integer 'thing-at-point 'thing-at-point-integer-at-point) |
|
|
|
|
|
|
|
(defun prelude-increment-integer-at-point (&optional inc) |
|
|
|
"Increment integer at point by one. |
|
|
|
|
|
|
|
With numeric prefix arg INC, increment the integer by INC amount." |
|
|
|
(interactive "p") |
|
|
|
(let ((inc (or inc 1)) |
|
|
|
(n (thing-at-point 'integer)) |
|
|
|
(bounds (bounds-of-thing-at-point 'integer))) |
|
|
|
(delete-region (car bounds) (cdr bounds)) |
|
|
|
(insert (int-to-string (+ n inc))))) |
|
|
|
|
|
|
|
(defun prelude-decrement-integer-at-point (&optional dec) |
|
|
|
"Decrement integer at point by one. |
|
|
|
|
|
|
|
With numeric prefix arg DEC, decrement the integer by DEC amount." |
|
|
|
(interactive "p") |
|
|
|
(prelude-increment-integer-at-point (- (or dec 1)))) |
|
|
|
|
|
|
|
(provide 'prelude-core) |
|
|
|
;;; prelude-core.el ends here |