Subject: Re: bug#8615: Please make sure v q removes the buffer for JPGs just like it does for other files

From: Kevin Rodgers <[email-masked]>
Date: Tue, 13 Dec 2011 00:12:49 -0700

On 12/10/11 3:17 AM, [email-masked] wrote:
> Erg... this is what I have so far,
>
> (eval-after-load "image-mode"
>    '(progn
>       (define-key image-mode-map "q"
>         (lambda () (interactive) (quit-window (not current-prefix-arg))))));bug#8615
> (eval-after-load "dired"
>    '(progn
>       (define-key dired-mode-map "q"
>         (lambda () (interactive) (quit-window (not current-prefix-arg))))))
> (eval-after-load "arc-mode"
>    '(progn
>       (define-key archive-mode-map "q";note the difference from the library name
>         (lambda () (interactive) (quit-window (not current-prefix-arg))))))
>
> i.e., an ever growing list. OK, I give up, you win. I'll use
>
> (global-set-key [remap quit-window]
>    (lambda () (interactive) (quit-window (not current-prefix-arg))))
>
> But please tell me how to then restore the virgin "q" behavior for one or two
> modes, e.g.,
>
> (eval-after-load "compile"
>    '(progn
>       (define-key compilation-mode-map ... ???
>
> I tired several things but nothing worked. Perhaps the "remap" above
> ruined it for everything.

Just a guess, assuming that the original behavior is (quit-window 
current-prefix-arg):

(defvar remap-quit-window-exceptions '()
   "List of `major-mode' symbols in which `quit-window' should not be remapped.")

(global-set-key [remap quit-window]
    (lambda () (interactive)
      (if (memq major-mode remap-quit-window-exceptions)
	 (quit-window current-prefix-arg)
        (quit-window (not current-prefix-arg)))))

;; (setq remap-quit-window-exceptions
;;       (cons 'compilation-mode remap-quit-window-exceptions))

-- 
Kevin Rodgers
Denver, Colorado, USA