From: Alin Soare <as1789@gmail.com>
To: emacs-devel@gnu.org
Subject: Midnight Commander Quick View
Date: Mon, 25 Aug 2014 05:26:28 +0300 [thread overview]
Message-ID: <87mwats3sb.fsf@gmail.com> (raw)
I needed quick view option, like in midnight commander, and I wrote this
code.
I want to ask if you know something that already exists and does a
similar job. My code is not complete -- for example, for large files, I
want to see only the header, not to load all the file.
In my emacs this code works as I expect to work. I did not test it
outside -- but it should work as well.
---
(setq lexical-binding t)
(require 'dired)
(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)))))
(save-window-excursion
(other-window 1)
(and buffer-read-only
(not (buffer-modified-p))
(kill-buffer (window-buffer)))))
(view-file-other-window f)
(other-window 1))))
(defun qv ()
(let ((i 0))
(let ((config (current-window-configuration)))
(delete-other-windows)
(split-window-sensibly)
(balance-windows)
(add-hook 'post-command-hook 'qv-update)
(lambda (message)
(defun exit ()
(setq-local quick-view-object nil)
(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)
(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 reply other threads:[~2014-08-25 2:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-25 2:26 Alin Soare [this message]
2014-08-25 14:38 ` Midnight Commander Quick View Stefan Monnier
2014-08-25 19:30 ` Alin
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=87mwats3sb.fsf@gmail.com \
--to=as1789@gmail.com \
--cc=emacs-devel@gnu.org \
/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).