26

What you want is called folding, and there are 2 ways you can do that. Outline-minor-mode This is a built-in minor mode that is exactly what org-mode uses to hide and display it's headlines. You can make sure it's always turned on in latex-mode with (add-hook 'LaTeX-mode-hook #'outline-minor-mode) The keybinds it defines are a little hard to use, so you ...


17

Try out vimish-fold. Features batteries included: activate minor mode, bind a couple of commands and everything will just work; it works on regions you select; it's persistent: when you close file your folds don't disappear; in addition to being persistent, it scales well, you can work on hundreds of files with lots of folds without adverse effects; it's ...


16

Hideshowvis adds clickable icons to the fringe, but for some strange reason it's not included in elpa or melpa. By default it shows a - in the fringe for code that can be folded, and then elides the content with a .... By also enabling hideshowvis-symbols it adds a + and makes the hinting for folded content a little louder. Hideshow itself also allows mouse ...


13

NB: much of this text came from an answer to a question that turned out to be a duplicate of this question. Some of the material is sufficiently different that it seemed worthwhile to add it to this question. Outline mode and the AUCTeX folding facilities are two different beasts that are meant to do broadly the same thing: hide and show selected parts of ...


8

There are more folding options for Emacs: http://wikemacs.org/wiki/Folding#Yafolding and Yafolding looks like the best for your case since it is based on indentation. It also includes a nice interface à-la Magit to discover the commands. However, that doesn't fully answer your question since it won't show the range of the fields out of the box. Yafolding ...


7

You can use TeX-fold-comment (C-c C-o C-c) to hide the comment. You need to enable TeX-fold-mode to make use of this functionality. See the AUCTeX manual on folding macros and environments for more information.


7

C-hig (emacs)Line Truncation As an alternative to continuation (*note Continuation Lines::), Emacs can display long lines by “truncation”. This means that all the characters that do not fit in the width of the screen or window do not appear at all. On graphical displays, a small straight arrow in the fringe indicates truncation at either end of ...


5

(add-hook '???-mode-hook (lambda () (setq-local orgstruct-heading-prefix-regexp "\\s-*/// ") (turn-on-orgstruct))) Replace ??? with the name of the mode, where you want this to happen. This will use /// as an indication of the beginning of the sub-tree, which can be folded. The number of * characters following the /// will ...


5

hs-minor-mode is a minor mode. Like most minor modes, it is buffer-specific and should be activated in each buffer where you want it. The error message you have is because the code you added to your init file activates (or tries to activate) hideshow when your init file loads, which is way too early : at that moment, the current buffer is most certainly some ...


4

Here is one approach to hide tags in folded view, and show them in any expanded view. (defun org-toggle-tag-visibility (state) "Run in `org-cycle-hook'." (message "%s" state) (cond ;; global cycling ((memq state '(overview contents showall)) (org-map-entries (lambda () (let ((tagstring (nth 5 (org-heading-components))) ...


4

There are a lot of different implementations of folding for emacs. Some are specific to a particular programming language or syntax, others are more generic. Of the generic ones, it sounds like yafolding is exactly what you're asking for. I tried it out, and while it feels somewhat slow, it does work. Another I tried is called origami, and I liked the ...


4

Something like this ? (defun my-cycle-previous-heading () (interactive) (outline-previous-heading) (org-cycle)) (define-key org-mode-map (kbd "C-x C-l") 'my-cycle-previous-heading)


4

Here a conf that do what you want: (defun py-outline-level () (let (buffer-invisibility-spec) (save-excursion (skip-chars-forward "\t ") (current-column)))) (defun hide-body-recenter () (interactive) (hide-body) (recenter)) (defun my-pythonFold-hook () (setq outline-regexp "[^ \t\n]\\|[ \...


4

I've tried Vimish fold, and it seems to do what you ask. Below is my setup for the keybindings: (require 'vimish-fold) (vimish-fold-global-mode 1) ;; this registers a region for future folding/unfolding (global-set-key (kbd "C-c v") #'vimish-fold) ;; this unregisters the region under point from folding/unfolding (global-set-key (kbd "C-c d") #'vimish-fold-...


4

While I don't think the fringe items can directly receive clicks (I might be wrong though), a possible hack would be to bind (kbd "<left-fringe> <double-mouse-1>") Since the first click would move the point to the beginning of the line that corresponds to the fringe icon, testing the value of (point) in your hypothetical (un)folding function ...


4

If you are asking about "absolute fold levels" then I can only guess that you want Org-mode like packages for the hierarchical tree-like structuring of files: Outshine It’s an extension library for outline-minor-mode that gives buffers in different major-modes the 'look-and-feel' of Org-mode buffers and enables the use of outorg and navi-mode on them. ...


4

It's not documented well enough, and possibly poorly named, but the hideshow function hs-hide-level will collapse all the blocks within the current block. That is, if your cursor is on the class ... line (or below it) in your example input, it will give you something very similar to your desired output. Since hideshow works with indentation I've found that ...


4

Overlay-based solution The preview.el library of auctex shows how something like that can be done with overlays. Font-lock based solution Another state-of-the-art package is hi-lock.el. It does not support setting and filtering text properties out of the box. Paintover is a modified reduced copy of hi-lock.el. It serves as concept study for solving this ...


3

You, sir, are looking for mode hooks: a set of functions that run every time you enter a buffer in a given mode. Note that mode hooks will not persist state between sessions, but your question really appears to be about running the same command every time you enter a buffer in a given mode. Now: for hideshow, the default binding C-c @ C-l is for hs-hide-...


3

Sorry, my documentation - if you can even call it that - is terrible. I imagine this is intimidating even if you're not new to elisp. ->> is a threading macro from the dash library, as wvxvw correctly points out. The easiest way to explore elisp is to use C-h f to read about functions you aren't familiar with. There should be a link to the source code ...


3

The Org manual section 2.4 Motion describes the key bindings to be used for navigation. For your case I think C-c C-p (outline-previous-visible-heading) Previous heading. would cater the requirement. When you are within a sub heading with lots of lines just use C-c C-p to navigate to the heading and press the Tab key to ...


3

A quick answer. If I get time I'll try to add a bit more later. Download isearch-prop.el, and load it. Use this command to make (...) invisible: (defun hide/show-parenthetical-text (&optional show) "Remove parentheses and text between them. With a prefix arg, show all invisible text." (interactive "P") (if show (...


3

Folding-mode will automatically fold files when opened if you call (folding-mode-add-find-file-hook) in your init file. The documentation, however, seems wrong. It says that you need to specify a file-local variable, but testing suggests that this is not needed.


3

I tried yafolding, seems to work (theres room for improvement on this, though) (require 'yafolding) (add-hook 'ruby-mode-hook 'yafolding-mode) (global-set-key (kbd "M-RET") 'yafolding-toggle-element) Possible alternatives: "yafolding", "hideshow", "folding.el", "imenu.el","vimish-fold"


2

C-u <tab> (#'org-cycle) will collapse all top-level trees. This might or might not be what you want. Alternately, you can move up to the parent heading (repeating it to go more than one level up) with C-c C-u (#'outline-up-heading), and then press tab to collapse it.


2

rst-toc can be used to navigate sections.


2

This answer does not address evil-vimish-mode. Instead, if you're agnostic about which particular package does the folding for you, you can try the built-in Hideshow mode (manual, wiki page). From the manual: Hideshow mode is a buffer-local minor mode that allows you to selectively display portions of a program, which are referred to as blocks. ...


2

The following code (lightly tested) takes advantage of the fact that org-mode is derived from outline-mode, which allows you to use the latter's functions. It simply jumps up headlines until it can't go any further, and then hides the subtree. (defun foldup () "Hide the entire subtree from root headline at point." (interactive) (while (ignore-errors (...


2

I have discovered the variable "TeX-fold-macro-spec-list". This variable contains a list of macros that are folded by "TeX-fold-mode". To fold the acronym macros (e.g.: \ac{}, \acp{}, \acf{}, \acpf{}), I have placed the following lines in my init.el file: ;; Set custom folds for Acronyms (add-to-list 'TeX-fold-macro-spec-list '("{1}" ("ac" "acf"))) (add-to-...


2

You did not implement alamo-forward-sexp correctly. If point is at begin_data almo-forward-sexp does not go to the block end, i.e., to the end of end_data but to the end of alamo-forward-sexp. A fairly complete alamo-forward-sexp must treat nested sexps correctly. Something like that is most often done via a stack. Below I give a simple version of a stack ...


Only top voted, non community-wiki answers of a minimum length are eligible