When I was editting text in minibuffer ,I entered "(" and ")". Then minibuffer shows message like "Matches (" for a few seconds. I do not want this message showing up. How to make this message function off? I think show-paren-mode is enough for me to check paren in minibuffer.
Example of key sequence and minibuffer:
time| minibuffer
----+------------
0 | M-x
1 | M-x (
2 | M-x ()
3 | Matches (
4 | M-x ()
I'm using Emacs 24.3 on MacOSX.
Thanks.
You can disable it by adding this to your init file
(setq blink-matching-paren nil)
Related
I have a block of code like this:
ec2_shell_exec(tag: "ls /
ec2_shell_exec(tag: "sudo yum install git-core
ec2_shell_exec(tag: "pwd
Whats the easiest way to add a ") to this block of code?
Please note, emacs runs in terminal mode aka -nw mode.
Interactively
C-M-% $ RET ") RET
don't forget to press 4 keys at the same time: Ctrl for C, Alt for M, and Shift-5 for %
if the above still does not work (e.g., you are in a terminal with emacs -nw), you can do M-x query-replace-regexp RET $ RET ") RET
Programmatically
(while (not (eobp)) ; you have to edit the condition!
(goto-char (line-end-position))
(insert "\")")
(forward-line))
A keyboard macro should be easy to type on most terminals:
Move to your first line
Start recording a keyboard macro with C-x (
Go to end of line with C-e
Type ")
Move down with C-n
Stop recording macro with C-x )
Type C-x e to replay once
Type e for each successive time you need to repeat it
Summarizing the two solutions here (for folks running emacs in terminal):
M-x query-replace-regexp RET $ RET ") RET
And
first highlight ec2_shell_exec(tag. And call mc/mark-all-like-this which is from multiple-cursor. You will see all ec2_shell_exec(tag being hightlighted. Now call end-of-line to move every cursor to the end. Finally, you can insert anything you want. Press C-g to end operation
video demo: https://www.youtube.com/watch?v=jNa3axo40qM
Thanks adobe and tom!
I have Emacs Windmove setup well and working, but I still have a small annoyance with it. There seems to be no way to slide one buffer over another buffer without switching the placement of both buffers. How can I slide a buffer over another buffer, displacing only that buffer.
Here's what I want to do:
___________ ___________ ___________
| | B | | | B | | | C |<-----
| A |_____| ---> | A |_____| ---> | A |_____| |
| | D | | | C | | | D | |
|____|_____| |____|_____| |____|_____| |
Buffer C opens up, ------^ With a key combo, maybe__|
covering buffer D I can slide up buffer C
to get back buffer D
EDIT: I forgot to mention I have some elisp that uses windmove to actually switch two buffers. The use case for what I want to do is that sometimes a buffer will open up in a certain window, covering up another buffer that I want to see. I want to slide the newly open buffer around without disturbing the other buffers, and to get the buffer back that was covered up. I hope that makes sense.
(defun slide-buffer (dir)
"Move current buffer into window at direction DIR.
DIR is handled as by `windmove-other-window-loc'."
(require 'windmove)
(let ((buffer (current-buffer))
(target (windmove-find-other-window dir)))
(if (null target)
(user-error "There is no window %s from here" dir)
(switch-to-prev-buffer)
(select-window target)
(switch-to-buffer buffer nil t))))
(defun slide-buffer-up () (interactive) (slide-buffer 'up))
(defun slide-buffer-down () (interactive) (slide-buffer 'down))
(defun slide-buffer-left () (interactive) (slide-buffer 'left))
(defun slide-buffer-right () (interactive) (slide-buffer 'right))
Bind it to C-S-<arrow>:
(define-key global-map (kbd "C-S-<up>") #'slide-buffer-up)
(define-key global-map (kbd "C-S-<down>") #'slide-buffer-down)
(define-key global-map (kbd "C-S-<left>") #'slide-buffer-left)
(define-key global-map (kbd "C-S-<right>") #'slide-buffer-right)
In your comment you say that you would like a "key combination to do it", meaning to (1) switch to the window showing buffer B and then (2) to switch the buffer shown in that window to buffer C.
How do you do that now? You use keys, no? So you already have a "key combination to do it". If you mean that you want a shorter key combination then write a command that chains together the commands bound to the keys you use now to do that.
There are several ways to do #1, and #2 is just C-x b C.
One way to do #1 is to use C-0 C-o in Icicles. It lets you pick a window by name, using completion. The command in question is icicle-choose-window-by-name.
Putting the two together, with Icicles you could use this code. Then hit F3 to do what you want.
(defun foo ()
(interactive)
(call-interactively #'icicle-choose-window-by-name)
(call-interactively #'switch-to-buffer))
(global-set-key [f3] 'foo)
There are other ways to choose a window, if you don't want to use Icicles. This is the place to start, when looking for info about selecting (navigating among) windows.
My Emacs frame looks like this:
+---------------------------+
| | |
| | |
| | B |
| A | |
| | |
| | |
| |-------------|
| | C |
+---------------------------+
C is usually a terminal with some kind of long-running process, like a web server or daemon. Unfortunately, all sorts of things like to switch the buffer in that window and occasionally it gets resized. How can I lock the buffer and height of window C?
If you don't want to be annoyed by window stealing and resizing, put the following lines in your .emacs for a definitive solution that works even with libraries like gud that tries to open a new frame when they can't steal your windows :
(see this answer for info on the following advice)
(defadvice pop-to-buffer (before cancel-other-window first)
(ad-set-arg 1 nil))
(ad-activate 'pop-to-buffer)
;; Toggle window dedication
(defun toggle-window-dedicated ()
"Toggle whether the current active window is dedicated or not"
(interactive)
(message
(if (let (window (get-buffer-window (current-buffer)))
(set-window-dedicated-p window
(not (window-dedicated-p window))))
"Window '%s' is dedicated"
"Window '%s' is normal")
(current-buffer)))
;; Press [pause] key in each window you want to "freeze"
(global-set-key [pause] 'toggle-window-dedicated)
and customize pop-up-windows variable to nil.
you could also use StickyWindows instead of window-dedicated feature.
One possibility is to dedicate the window to its buffer, using set-window-dedicated-p. This will not prevent the window from being resized manually, only protect it from being clobbered by display-buffer. For example,
(add-hook 'shell-mode-hook
(lambda ()
(interactive)
(set-window-dedicated-p (selected-window) 1)))
Replace shell-mode-hook as necessary.
This one also works fine (for emacs 24) https://lists.gnu.org/archive/html/help-gnu-emacs/2007-05/msg00975.html
(define-minor-mode sticky-buffer-mode
"Make the current window always display this buffer."
nil " sticky" nil
(set-window-dedicated-p (selected-window) sticky-buffer-mode))
You could use winner-mode to be able to undo the changes to be the window sizes.
You could also explicitly save and restore the window configuration in registers.
Please help me set up proper indentation in Emacs haskell-mode
When I'm trying to type down something like ADT or a record, I'm getting on the wrong column after pressing <ENTER>, and pressing <TAB> won't switch to the right one until I enter either | or ';'!
data MyADT = Oh
| Hi
| Hello
| <- the cursor is here again!
Trying to solve the problem I set
(define-key global-map (kbd "RET") 'reindent-then-newline-and-indent)
in my .emacs file, but it won't indent the current line on pressing <enter> too!
Another strange behaviour: indentation of case
oneChar c = case lookup c simpleEscapes of
| <- what? here?!
It sounds like you type <Enter> and then "|" and then <Tab>. If I do that, I get the same results. But if I type <Enter> and then <Tab> and then <Tab> again it automatically inserts the "|" and lines it up correctly, like so:
data MyADT = Oh
| Hi
|<Cursor>
When I check my haskell-mode version using M-x eval-expression haskell-version <Enter> I get "v2_4".
Emacs haskell-mode doesn't fully analyze the source code, so the "automatic" features are approximate, I think. Typing <Tab> several times on a new line cycles through several possible indentations, and also sometimes inserts text like the "|" for algebraic data types.
Caveat: I'm not a Haskell user, so take this with a grain of salt.
When you press RET after the Hello, Emacs doesn't know you're going to add a | (quick search shows you can have other symbols). The Haskell folks have deemed the proper indentation to be lined up directly below the H in Hello. If the indentation were to automatically line up with the | on the line above, then all the cases where you don't type a | will result in improper indentation. Damned if you do, damned if you don't...
Other programming modes (C/C++, Lisp, Tcl, ...) have the same problem - they cannot know ahead of time what you're going to put on the next line, so the indentation my not be what you'd hoped for.
One solution is to use "electric" keys, which is to say that they insert characters and also force re-indentation. You could easily define | to be electric with the following code:
(defun haskell-electric-| ()
"it's electric! (insert | and indent as long as the | follows whitespace)"
(interactive)
(insert "|")
(if (string-match-p "^\\s-*|" (buffer-substring (line-beginning-position)
(point)))
(haskell-indentation-indent-line)))
(define-key haskell-mode-map "|" 'haskell-electric-|)
I added a check to ensure that the | inserted is preceded by only whitespace, you can customize that however you want or remove the check altogether.
I presume there might also be other symbols in Haskell that would be worth making electric.
I commented the line
;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
And now I'm getting a good "tab" behavior: at least, it allows me to choose a column and does not tie down me to the one it likes. But no auto-indent at all annoys me a little bit, so I'm hoping it is a temporary solution
I want to write a function, similar hexl-find-file, that will open a gzipped file and show the contents in the hexl-mode. How would I do that?
Does this work for you?
(require 'jka-compr)
(defun hexl-find-file ()
"call find file and then jump into hexl mode"
(interactive)
(call-interactively 'find-file)
(hexl-mode 1))
The 'jka-compr provides the seamless compressed file handling, and the 'hexl-find-file just opens the file and turns on hexl-mode.
Turn on auto-compression-mode before you run hexl-find-file?
,----[ C-h f auto-compression-mode RET ]
| `auto-compression-mode' is an interactive compiled Lisp function
| -- loaded from "/usr/share/xemacs21/xemacs-packages/lisp/os-utils/auto-autoloads"
| (auto-compression-mode &optional ARG)
|
| Documentation:
| Toggle automatic file compression and uncompression.
| With prefix argument ARG, turn auto compression on if positive, else off.
| Returns the new status of auto compression (non-nil means on).
|
| Invoked with:
|
| M-x auto-compression-mode
`----