(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
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))
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 " ") "))")
(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)
(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.
(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)
(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)