When I open a PNG file in Emacs, I can navigate it using C-n, C-p, C-f and C-b, but how can I zoom in and out? I couldn't find anything here.
Ideally I would like to bind + and - to zoom in and out. Any pointers on this swould be great.
I introduce image+.
Usage from elisp file:
;;; Usage:
;; * To manupulate a image under cursor.
;;
;; M-x imagex-global-sticky-mode
;;
;; * C-c + / C-c -: Zoom in/out image.
;; * C-c M-m: Adjust image to current frame size.
;; * C-c C-x C-s: Save current image.
;;
;; * Adjusted image when open image file.
;;
;; M-x imagex-auto-adjust-mode
There is no direct way of doing it (e.g. C-x C-+ doesn't work), but you could try eimp (http://www.emacswiki.org/emacs/EmacsImageManipulation) -- I haven't tried it myself though..
Related
When you copy text from one buffer to another (M-w and C-y) it copy text with font-lock and when you paste it it display with colors from the buffer I copied the text. Is it possible to change that to make it display with font from new buffer?
See the doc for user options yank-excluded-properties and yank-handled-properties. And start with the doc for yank: C-h f yank. It tells you:
When this command inserts text into the buffer, it honors the
`yank-handled-properties' and `yank-excluded-properties'
variables, and the `yank-handler' text property. See
`insert-for-yank-1' for details.
IOW, just tell yank not to paste properties such as face and font-lock-face.
See also the Elisp manual, node Yanking.
I found (set-text-properties (point) (mark) nil) delete color of selected region.
I also want to remove read-only properties. But I don't know how to do it.(Sorry it is my question.)
With this in your setup:
(global-set-key (kbd "C-x C-r") (lambda()(interactive)(revert-buffer nil t)))
you'll need to do C-x C-s C-x C-r.
The problem occurs when customizing options in Emacs. Every time I click on a link a new buffer is created. How to force Emacs to use single buffer?
Try this:
(defadvice custom-buffer-create (before my-advice-custom-buffer-create)
"Exit the current Customize buffer before creating a new one, unless there are modified widgets."
(if (eq major-mode 'Custom-mode)
(let ((custom-buffer-done-kill t)
(custom-buffer-modified nil))
(mapc (lambda (widget)
(and (not custom-buffer-modified)
(eq (widget-get widget :custom-state) 'modified)
(setq custom-buffer-modified t)))
custom-options)
(if (not custom-buffer-modified)
(Custom-buffer-done)))))
(ad-activate 'custom-buffer-create)
As an alternative to my original answer (which I am not inclined to use myself), I thought I might suggest other ways in which you might deal with getting rid of lots of Customize buffers once you have finished customising things.
First, do note that simply pressing q will "Exit current Custom buffer according to `custom-buffer-done-kill'" (i.e. either bury it or kill it).
Second is to use M-x kill-matching-buffers RET \*Customize RET (and then confirm each one), but that's a bit tedious.
What I'd actually do is use ibuffer.
If you don't use it already, I recommend binding C-x C-b to ibuffer, which is a greatly enhanced alternative to the default list-buffers. I love it primarily for its filtering and grouping abilities, but it can do a great deal besides that.
(global-set-key (kbd "C-x C-b") 'ibuffer)
I also use the advice which can currently be found here at the Emacs Wiki so that ibuffer always opens with the buffer I came from selected.
That done, and from a Customize buffer, C-x C-b * M RET D y will kill all the Customize buffers. That is:
C-x C-b Open ibuffer (with point on the current Customize buffer entry)
* M Mark buffers by major mode...
RET ...select the mode (which defaulted to the major mode of the selected buffer, or otherwise type Custom-mode RET)
D y kill all marked buffers
Try it out; you'll probably like it. Searching for ibuffer will turn up other handy uses.
For instance, you could use / n ^\* RET / g tmp RET to separate out all buffers starting with * into a "tmp" group, so that they don't clutter up the group of buffers you are more likely to be interested in.
As with any major mode, use C-h m to read the built-in documentation.
I've been using emacs for few weeks and it's been great so far - coming from vim was easier than I expected (actually - emacs' keyboard shortcuts feel more... natural).
I have added few customizations like moving between buffers using M-Left/Right/Up/Down because C-x o felt a little bit too slow when I had four files opened at once.
So far - so good :-)
One thing bugs me though:
I open some splits using C-x 3 and C-x 2
I open the terminal in one of them using M-x term ENT
How do I switch to different split using keyboard?
Usual shortcuts obviously don't work - terminal is intercepting every emacs command, and I have to click on different buffer to activate it.
In term-mode, any regular C-x whatever keybinding becomes C-c whatever instead.
I'm not sure I understand your question. If you run M-x terminal, most of the key events are sent to the underlying terminal, so the standard C-x o binding and your M-Left are not available in the terminal.
Try using M-x shell to get a shell in one of the windows, and the navigation bindings you set up should still work.
In term-mode, type C-c b RET to switch to some other buffer.
That does what C-x b RET normally does.
This should do the trick to get C-x b working. You may have to add bindings for any custom move commands.
(add-hook 'term-mode-hook
(lambda ()
;; C-x is the prefix command, rather than C-c
(term-set-escape-char ?\C-x)
(define-key term-raw-map "\M-y" 'yank-pop)
(define-key term-raw-map "\M-w" 'kill-ring-save)))
BTW, there is a big difference between shell-mode and term-mode. The former integrates better with emacs (e.g. cd command). The latter is a full terminal emulation and can handle curses programs. They both have their place.
For a more generic answer dealing with emacs' windows, you can look at windmove, which started shipping with Emacs circa Emacs 22, I believe:
;;; Commentary:
;;
;; This package defines a set of routines, windmove-{left,up,right,
;; down}, for selection of windows in a frame geometrically. For
;; example, `windmove-right' selects the window immediately to the
;; right of the currently-selected one. This functionality is similar
;; to the window-selection controls of the BRIEF editor of yore.
;;
;; One subtle point is what happens when the window to the right has
;; been split vertically; for example, consider a call to
;; `windmove-right' in this setup:
;;
;; -------------
;; | | A |
;; | | |
;; | |-----
;; | * | | (* is point in the currently
;; | | B | selected window)
;; | | |
;; -------------
;;
;; There are (at least) three reasonable things to do:
;; (1) Always move to the window to the right of the top edge of the
;; selected window; in this case, this policy selects A.
;; (2) Always move to the window to the right of the bottom edge of
;; the selected window; in this case, this policy selects B.
;; (3) Move to the window to the right of point in the selected
;; window. This may select either A or B, depending on the
;; position of point; in the illustrated example, it would select
;; B.
;;
;; Similar issues arise for all the movement functions. Windmove
;; resolves this problem by allowing the user to specify behavior
;; through a prefix argument. The cases are thus:
;; * if no argument is given to the movement functions, or the
;; argument given is zero, movement is relative to point;
;; * if a positive argument is given, movement is relative to the top
;; or left edge of the selected window, depending on whether the
;; movement is to be horizontal or vertical;
;; * if a negative argument is given, movement is relative to the
;; bottom or right edge of the selected window, depending on whether
;; the movement is to be horizontal or vertical.
When I press C-x s (save-some-buffers) or C-x C-c (save-buffers-kill-terminal), Emacs displays the names of modified buffers one by one and asks what to do with each (save, diff, pass, ...). Pressing y one by one is slow. Pressing ! doesn't let you see what buffers are being saved.
How can I have the names of all modified buffers displayed first so that I can mark off some of them and save all the other quickly?
C-x C-b (M-x list-buffers) displays a list of all the buffers. Modified ones will be shown with a * next to them. You can mark a buffer for saving by pressing s. When you're done, press x to save all the buffers you marked.
Unfortunately, as far as I know, there's no way to show only the unsaved buffers or to sort them so they're all at the top.
(I actually prefer M-x ibuffer to M-x list-buffers, but ibuffer provides a similar feature.)
In emacs 23, with ibuffer :
'M-x ibuffer' (to open a list of buffers)
'*u' (start and u at the same time) to marked all unsaved buffers
'S' to save all marked buffers
Strangely enough, *u does not mark 'special' buffers like scratch, compilation, etc... I suppose i regexps on the name ...
Use ibuffer, which should come with all late-model emacsen. Put the following in your .emacs file:
(autoload 'ibuffer "ibuffer" "" t)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(defun my-ibuffer-load-hook ()
"Hook for when ibuffer is loaded."
(define-ibuffer-filter unsaved-file-buffers
"Only show unsaved buffers backed by a real file."
(:description "unsaved file buffers")
(and (buffer-local-value 'buffer-file-name buf)
(buffer-modified-p buf)))
(define-key ibuffer-mode-map (kbd "/ *") 'ibuffer-filter-by-unsaved-file-buffers)
)
;; (add-hook 'ibuffer-load-hook 'my-ibuffer-load-hook)
(eval-after-load 'ibuf-ext '(my-ibuffer-load-hook))
Then use C-x C-b to bring up the ibuffer list, and / * to show just unsaved buffers backed by a real file (so you don't see *scratch* in the list, for example). Mark the desired buffers with m and then save them with S.
The answer to the question in the title is to pass an argument to save-buffers-kill-emacs (or -kill-terminal), ie. use the key combo C-u C-x C-c which will silently save all buffers and exit (or C-u C-x s to just silently save all buffers).
In emacs 23
C-x C-b (M-x list-buffers) to view buffer list
m to mark buffers to save
S to save marked buffers
u to unmark buffers individually or M-x dired-unmark-all-marks for all
I have googled now for this question and found the solution here
http://johntellsall.blogspot.com.es/2013/03/emacs-save-all-modified-buffers.html
You have to add this config to your ~/.emacs.d/init.el emacs configuration
(global-set-key
(kbd "M-*")
(lambda ()
(interactive)
(save-some-buffers t)))
save and eval the buffer (M-evalb-buffer) of the init.el file, and then when you want to save all the modified files you only have to press Meta key with "*" as is indicated in the second line
I hope this solution works!
Juan
When I use dired mode to browse around and find a file I want to open in Emacs, dired opens a new buffer for each directory I visit when looking for the file each time I select a directory with Enter, which means I can end up with a lot of buffers I don't want:
. * newer 0 Fundamental c:/work/stackoverflow/batch/mydir/newer
% mydir 302 Dired by name c:/work/stackoverflow/batch/mydir/
% batch 616 Dired by name c:/work/stackoverflow/batch/
% stackoverflow 1017 Dired by name c:/work/stackoverflow/
% work 2545 Dired by name c:/work/
* *scratch* 190 Lisp Interaction
% *Completions* 162 Completion List
* *Messages* 2163 Fundamental
Is there any way to make dired re-use a single buffer? I tried M-x customize-group for group dired but didn't see anything promising in there.
Alternatively, does anyone have a macro to close all open dired buffers?
Use a (dired-find-alternate-file) instead of Enter
Also, see this page:
http://www.emacswiki.org/emacs/DiredReuseDirectoryBuffer
When browsing in dired instead of hitting enter to see a directory use i then it adds that directory to the current buffer.
I've never managed to get toggle-dired-find-file-reuse-dir to work reliably - I still end up with a variety of dired buffers open, and I'm never quite sure how.
Recently I discovered dired-single (http://www.emacswiki.org/cgi-bin/wiki/dired-single.el) which seems to work better for me. If you want it guarantees a single dired buffer, and also has a nice command dired-single-magic-buffer which will take you to the open dired buffer if you have one, and opens one if you don't.
There are some other alternatives if it isn't the multiple dired buffers per se that annoy, so much as the way they pollute your buffer lists. For example, elscreen.el has a dired plugin that keeps the dired buffers in their own tab, and the excellent ibuffer mode allows you to group dired buffers together when you list buffers.
Hope that helps!
Simon
From Xah Lee, at http://ergoemacs.org/emacs/emacs_dired_tips.html
;; Make dired open in the same window when using RET or ^
(put 'dired-find-alternate-file 'disabled nil) ; disables warning
(define-key dired-mode-map (kbd "RET") 'dired-find-alternate-file) ; was dired-advertised-find-file
(define-key dired-mode-map (kbd "^") (lambda () (interactive) (find-alternate-file ".."))) ; was dired-up-directory
In Emacs 28, you can just (setf dired-kill-when-opening-new-dired-buffer t). This works for either dired-find-file (RET) or dired-up-directory (^).
Dired+ lets you do this optionally, and it lets you toggle it on/off anytime.
See also http://www.emacswiki.org/emacs/DiredReuseDirectoryBuffer.