Function: ediff-toggle-regexp-match

ediff-toggle-regexp-match is an interactive and byte-compiled function defined in ediff-util.el.gz.

Signature

(ediff-toggle-regexp-match)

Documentation

Toggle between focusing and hiding difference regions matching a regexp.

Prompt the user for regular expression.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/vc/ediff-util.el.gz
(defun ediff-toggle-regexp-match ()
  "Toggle between focusing and hiding difference regions matching a regexp.
Prompt the user for regular expression."
  (interactive)
  (ediff-barf-if-not-control-buffer)
  (let ((regexp-A "")
	(regexp-B "")
	(regexp-C "")
	msg-connective alt-msg-connective alt-connective)
    (cond
     ((or (and (eq ediff-skip-diff-region-function
		   ediff-focus-on-regexp-matches-function)
	       (eq last-command-event ?f))
	  (and (eq ediff-skip-diff-region-function
		   ediff-hide-regexp-matches-function)
	       (eq last-command-event ?h)))
      (message "Selective browsing by regexp turned off")
      (setq ediff-skip-diff-region-function #'ediff-show-all-diffs))
     ((eq last-command-event ?h)
      (setq ediff-skip-diff-region-function ediff-hide-regexp-matches-function
	    regexp-A
	    (read-string
	     (format-prompt
	      "Ignore A-regions matching this regexp" ediff-regexp-hide-A))
	    regexp-B
	    (read-string
	     (format-prompt
	      "Ignore B-regions matching this regexp"
	      ediff-regexp-hide-B)))
      (if ediff-3way-comparison-job
	  (setq regexp-C
		(read-string
		 (format-prompt
		  "Ignore C-regions matching this regexp"
		  ediff-regexp-hide-C))))
      (if (eq ediff-hide-regexp-connective 'and)
	  (setq msg-connective "BOTH"
		alt-msg-connective "ONE OF"
		alt-connective 'or)
	(setq msg-connective "ONE OF"
	      alt-msg-connective "BOTH"
	      alt-connective 'and))
      (if (y-or-n-p
	   (format
	    "Ignore regions that match %s regexps, OK? "
	    msg-connective))
	  (message "Will ignore regions that match %s regexps" msg-connective)
	(setq ediff-hide-regexp-connective alt-connective)
	(message "Will ignore regions that match %s regexps"
		 alt-msg-connective))

      (or (string= regexp-A "") (setq ediff-regexp-hide-A regexp-A))
      (or (string= regexp-B "") (setq ediff-regexp-hide-B regexp-B))
      (or (string= regexp-C "") (setq ediff-regexp-hide-C regexp-C)))

     ((eq last-command-event ?f)
      (setq ediff-skip-diff-region-function
	    ediff-focus-on-regexp-matches-function
	    regexp-A
	    (read-string
	     (format-prompt
	      "Focus on A-regions matching this regexp" ediff-regexp-focus-A))
	    regexp-B
	    (read-string
	     (format-prompt
	      "Focus on B-regions matching this regexp" ediff-regexp-focus-B)))
      (if ediff-3way-comparison-job
	  (setq regexp-C
		(read-string
		 (format-prompt
		  "Focus on C-regions matching this regexp"
                  ediff-regexp-focus-C))))
      (if (eq ediff-focus-regexp-connective 'and)
	  (setq msg-connective "BOTH"
		alt-msg-connective "ONE OF"
		alt-connective 'or)
	(setq msg-connective "ONE OF"
	      alt-msg-connective "BOTH"
	      alt-connective 'and))
      (if (y-or-n-p
	   (format
	    "Focus on regions that match %s regexps, OK? "
	    msg-connective))
	  (message "Will focus on regions that match %s regexps"
		   msg-connective)
	(setq ediff-focus-regexp-connective alt-connective)
	(message "Will focus on regions that match %s regexps"
		 alt-msg-connective))

      (or (string= regexp-A "") (setq ediff-regexp-focus-A regexp-A))
      (or (string= regexp-B "") (setq ediff-regexp-focus-B regexp-B))
      (or (string= regexp-C "") (setq ediff-regexp-focus-C regexp-C))))))