I am reviewing some code in emacs that has a series of for loops that span several pages. The indentations done by the author are poor so it is not easy to tell where loops begin and end. I am using the highlight parenthesis mode to find where loops. However, it is often the case that the loop covers a few pages of code. Thus whenever I scroll to see more code the colors of the parenthesis change and I can't find where the loop ends. I've read other's posts about using mark and multi-window scrolling but this doesn't seem to work in my situation. Also locking the cursor position on the screen isn't helpful since it still moves with the screen. Any suggestions or advice?
相关问题
- Symbol's function definition is void: declare-
- Use JS/jQuery to scroll a div's content that h
- Jscrollpane - Fires a function when isAtBottom
- How can I set the SVN password with Emacs 23.1 bui
- Emacs shell: save commit message
相关文章
- ess-rdired: I get this error “no ESS process is as
- Emacs/xterm color annoyance on Linux
- SwiftUI automatically scroll to bottom in ScrollVi
- Android Edit Text Cursor Doesn't Appear
- Pipe less to Emacs
- Capturing the output of “diff” with org-babel
- Detect if cursor is hidden on Mac OS X
- emacs terminal mode: how to copy and paste efficie
Here is a modification of https://github.com/nschum/highlight-parentheses.el/blob/master/highlight-parentheses.el, which will permit you to scroll up or down without deleting the overlays. You can add additional
this-command
statements to suit your needs.I think you're looking for the wrong solution.
Place your cursor on loops starting parenthesis or curly bracket and press C-M-n This runs the command
forward-list
which will jump your cursor to the matching end paren or curly brace.Open the buffer, move to the starting paren, use C-x 3 to split the window in half, move to the new window, and use
forward-list
now you should have the starting paren in view on the left and the ending paren in view on the right.Alternatively, use hideshow to collapse blocks of code inside the loop to shrink the size and potentially fit it on one screen.
Also look into
follow-mode
this will allow you to view one buffer in multiple windows continuously effectively doubling or tripling the number of continuous lines of code you can see. This will work withshow-paren-mode
.Also if the indentation is really so terrible, run
mark-whole-buffer
andindent-region
to fix it up.You can use
forward-list
(C-M-n
) andbackward-list
(C-M-p
) to navigate forward and backward over a parenthetical group. (Also tryforward-sexp
(C-M-f
) andbackward-sexp
(C-M-b
)).Check out the EmacsWiki on Navigating Parentheses, the Emacs manual node on matching paretheses, and this SO thread on matching brackets.