From: Eshel Yaron Date: Tue, 21 Jan 2025 17:01:25 +0000 (+0100) Subject: Minor cleanups X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f65448ffa4895c43ca1113b20418bba94feecdef;p=emacs.git Minor cleanups --- diff --git a/lisp/dwim.el b/lisp/dwim.el index fa3949d4dc1..81faee243b7 100644 --- a/lisp/dwim.el +++ b/lisp/dwim.el @@ -23,7 +23,10 @@ (defvar dwim-hook nil) ;;;###autoload -(defun dwim () (interactive) (run-hooks 'dwim-hook)) +(defun dwim () + (interactive) + (or (run-hook-with-args-until-success 'dwim-hook) + (user-error "Cannot guess what you mean"))) (provide 'dwim) ;;; dwim.el ends here diff --git a/lisp/emacs-lisp/scope.el b/lisp/emacs-lisp/scope.el index 206d3e7feee..2a8193664a0 100644 --- a/lisp/emacs-lisp/scope.el +++ b/lisp/emacs-lisp/scope.el @@ -1098,7 +1098,7 @@ a (possibly empty) list of safe macros.") local-variable-if-set-p default-value set-default make-local-variable buffer-local-value add-to-list - add-hook run-hook-with-args run-hook-wrapped) + add-hook remove-hook run-hook-with-args run-hook-wrapped) (when-let* ((var-form (car forms)) ((memq (scope-sym-bare (car-safe var-form)) '(quote \`))) (var (cadr var-form)) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index b6b49bc3a7f..5627e0c5558 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -2550,7 +2550,7 @@ Interactively, if point is in a list (FUN . ARGS), then FUN-NAME is the name of FUN and ARG-NAMES is a list with placeholder argument names, one for each element of ARGS." (interactive (elisp-create-defun-interactive-arguments) emacs-lisp-mode) - (push-mark) + (push-mark nil t) (beginning-of-defun-raw) (goto-char (scan-sexps (point) 1)) (insert "\n\n(defun " fun-name " (" (string-join arg-names " ") "))") @@ -2664,10 +2664,6 @@ of TARGET." (prog-indent-sexp 'defun) (goto-char pos))) -;; (defun elisp-dwim (pos) -;; (interactive "d" emacs-lisp-mode) -;; (if (flymake-diagnostics pos))) - (put 'read-symbol-shorthands 'safe-local-variable #'consp) diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index d84b55e513d..4a9090ffe92 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -907,6 +907,13 @@ Return to original margin width if ORIG-WIDTH is non-nil." (message "No fix available for this diagnostic"))) (user-error "No diagnostic at this position"))) +(defun flymake-dwim-fix () + (when-let ((diags (flymake-diagnostics (point))) + (diag (seq-find #'flymake--diag-fix-function diags)) + ((flymake--fix-diagnostic diag))) + (flymake--update-diagnostics-listings (current-buffer)) + t)) + (defun flymake-read-diagnostic (prompt &optional project) "Prompt with PROMPT for a Flymake diagnostic in the current buffer. @@ -1614,6 +1621,7 @@ special *Flymake log* buffer." :group 'flymake :lighter (add-hook 'after-save-hook 'flymake-after-save-hook nil t) (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t) (add-hook 'eldoc-documentation-functions 'flymake-eldoc-function t t) + (add-hook 'dwim-hook 'flymake-dwim-fix nil t) ;; AutoResize margins. (flymake--resize-margins) @@ -1633,6 +1641,7 @@ special *Flymake log* buffer." :group 'flymake :lighter (remove-hook 'kill-buffer-hook 'flymake-kill-buffer-hook t) ;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t) (remove-hook 'eldoc-documentation-functions 'flymake-eldoc-function t) + (remove-hook 'dwim-hook 'flymake-dwim-fix t) ;; return margin to original size (flymake--resize-margins t)