[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Midnight Commander Quick View
From: |
Alin |
Subject: |
Re: Midnight Commander Quick View |
Date: |
Mon, 25 Aug 2014 22:30:36 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
>> (setq lexical-binding t)
>
> Don't do that. This will set lexical-binding during *execution*,
> whereas that option is needed during compilation.
> Furthermore, it will set it such that it will affect everything rather
> than only code in this file.
>
>
setting lexical-binding has nothing to do with the code (apart that it
must be set buffer-local, for this code to work).
Here is an updated version, that works quite nice, and is fast.
(defun qv ()
(let ((i 0))
(let ((config (current-window-configuration)))
(defun qv-remove-other-buffer ()
(save-window-excursion
(other-window 1)
(and buffer-read-only
(not (buffer-modified-p))
(kill-buffer (window-buffer)))))
(defun qv-update ()
(let ((f (dired-get-filename t t)))
(when (and (stringp f) (file-regular-p f)
(< (nth 7 (file-attributes f)) 1e7))
(when (not (equal (window-buffer)
(save-window-excursion
(window-buffer (other-window 1)))))
(qv-remove-other-buffer))
(let ((auto-mode-alist))
(view-file-other-window f))
(other-window 1)
(message "View file %s. Press C-q to quit quick-view." f))))
(delete-other-windows)
(split-window-sensibly)
(balance-windows)
(add-hook 'post-command-hook 'qv-update 'at-the-end t)
(lambda (message)
(defun exit ()
(setq-local quick-view-object nil)
(qv-remove-other-buffer)
(define-key dired-mode-map
[(control ?c) (control ?q)]
qv-binding)
(setq i (1- i))
(set-window-configuration config)
(remove-hook 'post-command-hook 'qv-update t)
(message "exit qv"))
(apply message '())))))
(setq-local qv-binding
(lambda (&optional arg)
(interactive)
(setq-local quick-view-object (qv))
(define-key dired-mode-map [(control ?c) (control ?q)]
(lambda (&optional arg)
(interactive)
(dired-next-line 1)
(apply quick-view-object (list 'exit))))))
(define-key dired-mode-map
[(control ?c) (control ?q)]
qv-binding)
--
No GNUs is bad news.