summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2021-03-26 11:45:31 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2021-03-26 11:45:31 -0400
commitbc506441372726341b6d95abb85011dba6d897ea (patch)
treeb090286de011b89b8ac0f444c3569afdcf751754 /lisp
parent28d0654943ca4e66cdcb498c53dc8aaa41fe2fad (diff)
downloademacs-bc506441372726341b6d95abb85011dba6d897ea.tar.gz
emacs-bc506441372726341b6d95abb85011dba6d897ea.tar.bz2
emacs-bc506441372726341b6d95abb85011dba6d897ea.zip
* lisp/obsolete/tpu-extras.el: Avoid defadvice
(tpu--respect-bottom-scroll-margin): New function, extracted from `newline`s defadvice. (newline, newline-and-indent, do-auto-fill): Delete defadvice. (tpu-set-scroll-margins): Use advice-add instead of `ad-enable-advice`+`ad-activate`. Use an explicit arg instead of `called-interactively-p`.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/obsolete/tpu-extras.el29
1 files changed, 8 insertions, 21 deletions
diff --git a/lisp/obsolete/tpu-extras.el b/lisp/obsolete/tpu-extras.el
index 5d59945c562..f375e05d8ac 100644
--- a/lisp/obsolete/tpu-extras.el
+++ b/lisp/obsolete/tpu-extras.el
@@ -368,34 +368,22 @@ A repeat count means scroll that many sections."
(and (< (point) top) (recenter (min beg top-margin))))))
;; Advise the newline, newline-and-indent, and do-auto-fill functions.
-(defadvice newline (around tpu-respect-bottom-scroll-margin activate disable)
+(defun tpu--respect-bottom-scroll-margin (orig-fun &optional &rest args)
"Respect `tpu-bottom-scroll-margin'."
(let ((beg (tpu-current-line))
- (num (prefix-numeric-value (ad-get-arg 0))))
- ad-do-it
+ (num (prefix-numeric-value (car args))))
+ (apply orig-fun args)
(tpu-bottom-check beg num)))
-(defadvice newline-and-indent (around tpu-respect-bottom-scroll-margin)
- "Respect `tpu-bottom-scroll-margin'."
- (let ((beg (tpu-current-line)))
- ad-do-it
- (tpu-bottom-check beg 1)))
-
-(defadvice do-auto-fill (around tpu-respect-bottom-scroll-margin)
- "Respect `tpu-bottom-scroll-margin'."
- (let ((beg (tpu-current-line)))
- ad-do-it
- (tpu-bottom-check beg 1)))
-
-
;;; Function to set scroll margins
;;;###autoload
-(defun tpu-set-scroll-margins (top bottom)
+(defun tpu-set-scroll-margins (top bottom &optional emit-msg)
"Set scroll margins."
(interactive
"sEnter top scroll margin (N lines or N%% or RETURN for current value): \
-\nsEnter bottom scroll margin (N lines or N%% or RETURN for current value): ")
+\nsEnter bottom scroll margin (N lines or N%% or RETURN for current value): \
+\np")
;; set top scroll margin
(or (string= top "")
(setq tpu-top-scroll-margin
@@ -411,10 +399,9 @@ A repeat count means scroll that many sections."
(/ (1- (+ (* (string-to-number bottom) 100) (window-height)))
(window-height)))))
(dolist (f '(newline newline-and-indent do-auto-fill))
- (ad-enable-advice f 'around 'tpu-respect-bottom-scroll-margin)
- (ad-activate f))
+ (advice-add f :around #'tpu--respect-bottom-scroll-margin))
;; report scroll margin settings if running interactively
- (and (called-interactively-p 'interactive)
+ (and emit-msg
(message "Scroll margins set. Top = %s%%, Bottom = %s%%"
tpu-top-scroll-margin tpu-bottom-scroll-margin)))