Skip to content

indent-region with hideshowvis-symbols changes code #8

@rdiaz02

Description

@rdiaz02

If I have hideshowvis-symbols enabled, and the regions are hidden and showing the yellow rectangle on the right, if I select a region (say, the whole buffer) and then press TAB (for indent-for-tab-command ) the code is changed, with parts of it removed (parentheses or even complete expressions).

This is code to show the problem:

  • Start emacs -Q and evaluate this code:
(add-hook 'prog-mode-hook 'hs-minor-mode)
(add-to-list 'load-path "wherever-hideshowsivis-is")
(require 'hideshowvis)

(add-hook 'emacs-lisp-mode-hook 'hideshowvis-enable)
;; the next line is the culprit
(add-hook 'emacs-lisp-mode-hook 'hideshowvis-symbols)

Now, in that same emacs, open a file like, for example, this one:

(defun a ()
  (setq b 93))


(defun a2 ()
  (setq b 93
	))

Now, in the file hs-hide-all. It will show this:
hs1

Then, mark the whole buffer and press TAB (or M-x indent-region). And notice the modeline shows the buffer has been changed (indent-region could do that, but it should not have changed anything in this buffer)

hs2

In fact, this is how the code looks if we hs-show-all:

hs3

In the first block, (setq b 93) has been erased and in the second block one closing parenthesis has been erased.

If we do not enable hideshow-symbols none of this happens, as far as I can tell.

EDIT: a simple, though brutal and ugly, way of dealing with this for now is advicing indent-region:

(advice-add 'indent-region :before (lambda (&rest args) (hs-show-all)))

I do not know if there is a better way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions