0

iimage-mode rebinds C-l to iimage-recenter instead of the usual recenter-top-bottom.

  1. What is the logic behind this remapping? If it's there, I'm guessing it must be somehow useful, despite that the original mapping to recenter is normally so sacred to emacs users.
  2. How do I disable the new mapping and return to the old one? The attempt below is not good.
 (add-hook 'iimage-mode-hook
          (lambda()
            (global-unset-key "\C-l")
            ))

(As an aside, stackexchange's markdown for code blocks used to handle elisp just fine, until recently.)

1

About your first question:

What is the logic behind this remapping? If it's there, I'm guessing it must be somehow useful, despite that the original mapping to recenter is normally so sacred to emacs users.

You should have a look at the description of iimage-recenter:

Re-draw images and recenter.

The "re-draw images" part is not covered by recenter-top-bottom. If you look at the code you see that this function removes essentially the 'display 'image property and adds it again afterwards. That destroys the cache for the image and reads it anew from the file. I think

(clear-image-cache (expand-file-name "filename"))

instead would also do the trick.

About your second question:

How do I disable the new mapping and return to the old one? The attempt below is not good.

iimage-mode uses the minor-mode map iimage-mode-map. You can just unset the key there:

(define-key iimage-mode-map "\C-l" nil)

The variable iimage-mode-map is defined by defvar in iimage.el. If you already require iimage in your initialization put the above line behind that require-statement. If iimage is loaded automatically by some other package put the following line in your initialization files:

(eval-after-load "iimage" '(define-key iimage-mode-map "\C-l" nil))
| improve this answer | |
  • iimage-mode is invaluable, but it's puzzling that it's so heavy handed in terms of expectation of usage. I may sometimes start from the images and write the text afterwards, but quite often what works for me is to write the text first and produce the images later. In that case I don't want iimage-mode to protest that the images are not ready. – Calaf Jul 4 '17 at 21:08
  • Something's not right: Symbol's value as variable is void: iimage-mode-map. Is it not necessary to wrap this line in a hook? Otherwise it fails unless iimage-mode has already loaded. – Calaf Jul 4 '17 at 23:52
  • @Calaf See my edit at the end of the answer. – Tobias Jul 5 '17 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.