]> git.eshelyaron.com Git - emacs.git/commitdiff
Minor cleanups
authorEshel Yaron <me@eshelyaron.com>
Tue, 21 Jan 2025 17:01:25 +0000 (18:01 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 21 Jan 2025 17:01:25 +0000 (18:01 +0100)
lisp/dwim.el
lisp/emacs-lisp/scope.el
lisp/progmodes/elisp-mode.el
lisp/progmodes/flymake.el

index fa3949d4dc19020429d56201b4ebca33476b0339..81faee243b7edeecb18ea64322b1a88b019b0aa5 100644 (file)
 (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
index 206d3e7feee71ec62cfaf77dc3a903094f7254a8..2a8193664a0badc32cd18adec643fd00fb91a561 100644 (file)
@@ -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))
index b6b49bc3a7fde783e7ea8b1d755b4523313856f0..5627e0c55580ebe226aacdd9124def253fc7e894 100644 (file)
@@ -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)))
-
 \f
 (put 'read-symbol-shorthands 'safe-local-variable #'consp)
 
index d84b55e513dbb4ee3abaa07a7dbc05cd286e22c0..4a9090ffe92077647eb10cb2bd6657e67c1bd304 100644 (file)
@@ -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)