(defun remove-hook-at-point ()
(interactive)
(unless (or (eq major-mode 'help-mode)
(string= (buffer-name) "*Help*"))
(error "Only for help-mode"))
(let ((orig-point (point)))
(save-excursion
(when-let* ((hook (progn (goto-char (point-min)) (symbol-at-point)))
(function-at-point
(when (and (re-search-forward
(format "s value is[\s\n]" hook) nil t)
(sexp-at-point))
(end-of-sexp)
(backward-char 1)
(catch 'break
(while t
(condition-case err
(backward-sexp)
(scan-error (throw 'break nil)))
(let ((bounds (bounds-of-thing-at-point 'sexp)))
(when (< (car bounds) orig-point (cdr bounds))
(throw 'break (sexp-at-point)))))))))
(when (yes-or-no-p (format "Remove %s ? " function-at-point))
(message "Removing from the value of %s the function %s." hook function-at-point)
(remove-hook hook function-at-point)
(revert-buffer nil t))))))

2 个赞