From: Alin <as1789@gmail.com>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: Midnight Commander Quick View
Date: Mon, 25 Aug 2014 22:30:36 +0300 [thread overview]
Message-ID: <87zjespdsz.fsf@gmail.com> (raw)
In-Reply-To: <jwvd2bomy89.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 25 Aug 2014 10:38:42 -0400")
Stefan Monnier <monnier@IRO.UMontreal.CA> 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.
next prev parent reply other threads:[~2014-08-25 19:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-25 2:26 Midnight Commander Quick View Alin Soare
2014-08-25 14:38 ` Stefan Monnier
2014-08-25 19:30 ` Alin [this message]
2014-08-26 17:45 ` Stefan Monnier
2014-08-27 6:33 ` Alin
-- strict thread matches above, loose matches on Subject: below --
2014-09-11 14:51 Midnight commander quick view Alin Soare
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zjespdsz.fsf@gmail.com \
--to=as1789@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@IRO.UMontreal.CA \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).