How to make occur mode select the window of buffer `*Occur*`?

[Origin]: https://emacs.stackexchange.com/questions/13212/how-to-make-occur-mode-select-the-window-of-buffer-occur

Is it possible to make the occur mode grab the cursor (point)?, right now when I do M-x occur and search anything in a buffer, it will open the new buffer with the findings but the cursor stays in the buffer instead going to the findings.

I have to do C-x 0 to go to the other buffer everytime I do a search.

I tried doing it with a blank init.el just in case is helm or any other package, but I haven’t been able to make it focus the cursor on the new buffer.

( I know that there’s the helm-occur that does that, but is it possible with any command or function to make the cursor change to the active buffer when that command opens a new buffer? )

shareimprove this question

Occur has a hook, occur-hook, that contains a list of functions to run after a match is found. So we can add a hook to jump to the *Occur* window there:

(add-hook 'occur-hook
          '(lambda ()
             (switch-to-buffer-other-window "*Occur*")))
Advertisements

fix to get smooth scrolling in emacs?

[Originally Posted By]: http://stackoverflow.com/questions/3631220/fix-to-get-smooth-scrolling-in-emacs

I find myself wanting to use Emacs, mostly because of org-mode, but I’m having a lot of trouble getting used to the jerky scrolling behavior. I know this is a well-known problem/eccentricity of Emacs and that there are various ways to minimize jerkiness when scrolling. But nothing I’ve tried so far works very well at all.

The main suggestions I’ve seen are (setq scroll-conservatively 10000) or to use the more comprehensive fix available in smooth-scrolling.el . I think both of these might work okay for me, but both fail miserably when I hold down the up-arrow and down-arrow key to get repeated scrolling up or down. When I do this the screen freezes and I see the scroll-indicator-bar in the scroll margin move up or down. The screen does not refresh until I stop holding down the up-arrow or down-arrow key.

If I repeatedly press up-arrow or down-arrow then I do get behavior close to what I want, i.e., the screen scrolls smoothly and cursor key does not get reset to middle of screen. But this is undesirable because (1) it requires repeated keypresses and (2) I assume the scrolling is at a slower rate than what I should be able to get in better solution.

The problem with holding the cursor keys down seems to me to be that the repeat rate of up-arrow or down-arrow is so fast that it triggers emacs to stop the screen refresh until key is released. I wonder whether a possible fix for me would be to add some lag into the key-repeat rate or the rate at which the next/previous line function is called in emacs.

I haven’t seen this reported as a problem by others and I wonder whether other people have experienced same behavior. What’s best way to fix things so I can hold the up/down arrow keys down and have repeat rate that’s slow enough so that the screen doesn’t freeze?

UPDATE: The above behavior is what I get when I run emacs on Win7/64. On same machine when I run emacs inside a VirtualBox VM running Ubuntu 10.04 it’s no problem to get scrolling that works fine even when cursor keys are held down.

shareimprove this question

I had the same problem! Tried all the scroll-* settings, didn’t help when holding down arrow. But found this on gnu.emacs.help which finally worked (for me at least):

(setq redisplay-dont-pause t)

This is what I have in .emacs for now:

(setq redisplay-dont-pause t
  scroll-margin 1
  scroll-step 1
  scroll-conservatively 10000
  scroll-preserve-screen-position 1)
shareimprove this answer

Try this:

;; scroll one line at a time (less "jumpy" than defaults)
(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ; one line at a time
(setq mouse-wheel-progressive-speed nil)            ; don't accelerate scrolling
(setq-default smooth-scroll-margin 0)
(setq scroll-step 1
      scroll-margin 1
      scroll-conservatively 100000)

And use pager.el.

;; Pager
(require 'pager-default-keybindings)

That’s what I want 🙂 Enjoy!

shareimprove this answer

MACRO COUNTERS

[Originally Posted By]: http://pragmaticemacs.com/emacs/macro-counters/

I’ve posted about using keyboard macros to record and play back repetitive tasks. Macros include acounter which lets you insert numerical values that increment each time the macro is called.

For example, go to a new line and start a macro with C-x ( and then hit C-a to move to the start of the line, C-x C-k C-i to insert the macro counter (initially zero) and then RET to go to a new line andC-x ) to stop the recording. Run the macro a few times with C-x e and then just e to repeat the macro and you’ll get something like this:

0
1
2
3
4

The counter starts at zero every time you define a new macro. To set it to another value, use C-x C-k C-c before defining or invoking a macro.