Skip to content

Commit 43659ed

Browse files
committed
feat(core): enable --ignore-whitespace for +apply-patch-dwim
1 parent 448aca7 commit 43659ed

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

core/me-lib-extra.el

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,13 @@ RECURSIVE is non-nil."
316316
(user-error "This buffer isn't bound to a file")))
317317

318318
(defvar +apply-patch-dwim-proj-dir nil)
319+
(defvar +apply-patch-dwim-extra-options "--ignore-whitespace")
320+
(autoload 'project-files "project")
321+
(autoload 'diff-hunk-next "diff-mode")
322+
(autoload 'diff-hunk-file-names "diff-mode")
319323

320324
(defun +patch-get-patched-files (patch-buff)
325+
"Get the list of the patches A/B files mentioned in PATCH-BUFF."
321326
(with-current-buffer (get-buffer patch-buff)
322327
(save-excursion
323328
(goto-char (point-min))
@@ -372,13 +377,16 @@ When a region is active, propose to use it as the patch buffer."
372377
((length> results 1) (completing-read "Select a target directory: " results))
373378
(t (read-directory-name "Cannot deduce the target directory, select one: ")))))
374379
(when (y-or-n-p (format "Apply patch %S in directory %S?" (file-name-nondirectory (buffer-file-name patch-buf)) target-dir))
375-
;; Hakish way of forcing `ediff-patch-file' to use the `target-file-or-dir' without asking
376-
(cl-letf (((symbol-function 'read-file-name)
377-
(lambda (&rest args)
378-
(if (length= patch-files 2)
379-
(expand-file-name (caar candidates) target-dir)
380-
target-dir))))
381-
(ediff-patch-file nil patch-buf))))))))
380+
;; Add the `+apply-patch-dwim-extra-options' to `ediff-patch-options'
381+
(require 'ediff-ptch) ; for `ediff-patch-options'
382+
(let ((ediff-patch-options (format "%s %s" ediff-patch-options +apply-patch-dwim-extra-options)))
383+
;; Hackish way of forcing `ediff-patch-file' to use the `target-file-or-dir' without asking
384+
(cl-letf (((symbol-function 'read-file-name)
385+
(lambda (&rest args)
386+
(if (length= patch-files 2)
387+
(expand-file-name (caar candidates) target-dir)
388+
target-dir))))
389+
(ediff-patch-file nil patch-buf)))))))))
382390

383391
;;;###autoload
384392
(defun +clean-file-name (filename &optional downcase-p)

0 commit comments

Comments
 (0)