From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alin Newsgroups: gmane.emacs.devel Subject: Re: Midnight Commander Quick View Date: Mon, 25 Aug 2014 22:30:36 +0300 Message-ID: <87zjespdsz.fsf@gmail.com> References: <87mwats3sb.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1408995079 17563 80.91.229.3 (25 Aug 2014 19:31:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Aug 2014 19:31:19 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 25 21:31:11 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XLzyx-0002eT-63 for ged-emacs-devel@m.gmane.org; Mon, 25 Aug 2014 21:31:11 +0200 Original-Received: from localhost ([::1]:50284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLzyw-0003Yq-EB for ged-emacs-devel@m.gmane.org; Mon, 25 Aug 2014 15:31:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLzyn-0003PX-I6 for emacs-devel@gnu.org; Mon, 25 Aug 2014 15:31:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XLzyh-0004BA-JJ for emacs-devel@gnu.org; Mon, 25 Aug 2014 15:31:01 -0400 Original-Received: from mail-we0-x22d.google.com ([2a00:1450:400c:c03::22d]:34666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLzyh-0004Aw-Ar for emacs-devel@gnu.org; Mon, 25 Aug 2014 15:30:55 -0400 Original-Received: by mail-we0-f173.google.com with SMTP id q58so13781548wes.32 for ; Mon, 25 Aug 2014 12:30:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:in-reply-to:references:user-agent:cc:date :message-id:mime-version:content-type; bh=aEyPuRS4Y0O3nGUsRHiQ6s88RR+jxEdQISrSuTDRzC8=; b=aNpL8iahtKXynd0NQ2VDU859O0t0uRtNUl/5gbMKtHwVGdkXuKoUPiOgdeYk72DPcF EEpTB09DXWfmYB36nuspEEwT2PCH8719RCpm/leXBJ+sKEJwHyvnhNXh1go2Eb91MXUS GZSHx1CjUeLofU6eTxwZpttTj7fDlodiqr/xRGsMfgPSvbHexrhieW12gH/82f2C3dus S36n+iTlDmJhcWZ9tB2VJssS/f/P4ObZRJD0wSrLDNxmsEwpa/WZ+2qOSQjQVYJgR8tm 6mQFZfUA9cfLcEFmqU1ivKuiKQodRdKqq7/SLGVxTsDyj98dxWzzl1wlzWmyIymjADu8 yqVQ== X-Received: by 10.194.161.231 with SMTP id xv7mr11745786wjb.78.1408995054254; Mon, 25 Aug 2014 12:30:54 -0700 (PDT) Original-Received: from ThinkPad-T420 ([109.102.134.178]) by mx.google.com with ESMTPSA id ua8sm1948739wjc.7.2014.08.25.12.30.52 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 25 Aug 2014 12:30:53 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Mon, 25 Aug 2014 10:38:42 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22d X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:173827 Archived-At: Stefan Monnier 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.