Skip to content

Latest commit

 

History

History
86 lines (67 loc) · 3.3 KB

README.org

File metadata and controls

86 lines (67 loc) · 3.3 KB

look-mode: a minor mode for skimming files

Functions and keybindings

Main: look-at-files (&optional add)

looks at marked files. If no files are marked (or only one), prompt user for a file glob.

Navigation:

  • C-. or M-n: look-at-next-file (&optional arg)
  • C-, or M-p: look-at-previous-file (&optional arg)
  • M-# : look-at-nth-file (n)
  • M-/ : look-at-specific-file (file)

Search

  • C-s : look-re-search-forward (regex)
  • C-r : look-re-search-backward (regex)

List manipulations

  • : look-remove-this-file
  • : look-insert-file (file)
  • M-R : look-reverse-files
  • M-~ : look-move-current-file (pos)
  • M-^ : look-sort-files (pred)
  • look-reset-file-settings nil
  • look-customize-defaults nil
  • look-filter-files (pred &optional arg)

What it does

Takes a list of files and provides an interface to open each one in turn in a temporary, writable buffer (look). Defines navigation keybindings to flip through the list of files (forward: “M-n” or “C-.”, reverse: “M-p” or “C-,”). Indicates in the header the current file name and the number of files in the list in the forward and reverse directions. Usually handles default major modes properly.

Why?

I find this useful for skimming through large batches of nearly identical files, like configs and logs, or for skimming through a directory full of unfamiliar PDFs. Originally, I wrote this to view photos in Emacs, but I don’t actually use it much for that.

Emacs handles images, but photographs are frequently larger than my screen. I found EmacsImageManipulation mode useful for resizing the photos, but the problem is that the file has to be opened in a writable buffer. This presents the danger of accidentally altering an image file when I only want to view it temporarily (and resize it to my window size). Look-mode eliminates this danger by inserting the file into a temporary buffer.

What else?

Directories are culled from the file list and may be listed on the header line. The directory list is by default recursively searched. This can be turned off from the Customize interface for look.

After I wrote this, I realized that it would be great for reading and sorting arXiv abstracts, so I wrote another minor-mode piggybacking on this one called ArxivReader.

Deficiencies

Can’t deal with *.zip files. Haven’t tried it on tar-ed or gz-ed files yet.

Acknowledgements/History

Look-mode is a minor mode originally written for use with EmacsImageManipulation mode. This should work under all operating systems, but has not been tested under MS-dos/windows.

Thanks to Lennart Borgman for prodding and Nikolaj Schumacher for a solution (`directory-files` and `wildcard-to-regexp`). I then discovered that `file-expand-wildcards` is a better function for this program because it works properly on wildcards going into subdirectories:

(file-expand-wildcards ”/.jpg”) ;; this works (directory-files “./” nil (wildcard-to-regexp ”/.jpg”)) ;; this returns nil

Vapniks made major improvements to this code in 2015. In 2022, I finally merged most his code with my local copy, fixing some bugs and leaving out some features that I’m not ready for.