Function: magit-diff-set-context

magit-diff-set-context is a byte-compiled function defined in magit-diff.el.

Signature

(magit-diff-set-context FN)

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-diff.el
(defun magit-diff-set-context (fn)
  (when (derived-mode-p 'magit-merge-preview-mode)
    (user-error "Cannot use %s in %s" this-command major-mode))
  (let* ((def (if-let ((context (magit-get "diff.context")))
                  (string-to-number context)
                3))
         (val magit-buffer-diff-args)
         (arg (seq-find (##string-match "^-U\\([0-9]+\\)?$" %) val))
         (num (if-let ((str (and arg (match-str 1 arg))))
                  (string-to-number str)
                def))
         (val (delete arg val))
         (num (funcall fn num))
         (arg (and num (not (= num def)) (format "-U%d" num)))
         (val (if arg (cons arg val) val)))
    (setq magit-buffer-diff-args val))
  (magit-refresh))