syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

spacemacs/toggle-whitespace-cleanup cannot locally disable whitespace cleanup #8221

Closed jakemcarthur closed 4 days ago

jakemcarthur commented 7 years ago

Description :octocat:

spacemacs/toggle-whitespace-cleanup cannot locally disable whitespace cleanup

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: The trailing whitespace is removed.

Expected behaviour: :heart: :smile: The trailing whitespace is not removed.

System Info :computer:

nixmaniack commented 7 years ago

Well - it is expected behaviour based on value of dotspacemacs-whitespace-cleanup. If it's nil, even if you enable whitespace-cleanup locally for the buffer - the cleanup function doesn't know how to cleanup trailing whitespace i.e. whether to cleanup all, trailing or just changed and hence it doesn't cleanup anything.

What you can do currently is: set dotspacemacs-whitespace-cleanup to your expected behaviour i.e. all, trailing or changed and then toggle it (off) globally with SPC t C-S-w [(spacemacs/toggle-global-whitespace-cleanup)] and then you can turn on/off for individual buffers.


May be we can improve this by having default local/global value specified in case the value is nil so that if user invokes this functionality we're able to set it up appropriately. Open to discussion.

jakemcarthur commented 7 years ago

My desire is for it to be on by default and off for specific buffers. It seems wrong that I can't toggle it off per-buffer when I set it to all. I accept that I would have to follow the procedure you outlined to do the opposite (off by default and on for specific buffers), so that part of my original bug report should probably be removed (edit: I just did this).

nixmaniack commented 7 years ago

This looks like an issue then. I might look into it if I find some time later this weekend.

liweitianux commented 7 years ago

Hello,

I can reproduce this issue. I have dotspacemacs-whitespace-cleanup set to trailing, which adds the delete-trailing-whitespace to the global hook before-save-hook. For example, my Spacemacs has before-save-hook: (delet-trailing-whitespace spacemacs//python-sort-imports).

Then, when I try to locally disable the whitespace cleanup for a buffer by SPC t W (i.e., spacemacs/toggle-whitespace-cleanup), which basically executes (remove-hook 'before-save-hook 'delete-trailing-whitespace t). However, this fails because there is NO local hook before-save-hook from which to remove the function delete-trailing-whitespace.

Cheers, Aly

asok commented 7 years ago

I have a similar issue on develop. I have the variable dotspacemacs-whitespace-cleanup set to 'trailing. In the markdown mode I'm unable to have double space at the end of a line (which is a line break in markdown).

After doing M-x eval-expression RET (remove-hook 'before-save-hook 'delete-trailing-whitespace) RET I'm able to save the trailing whitespaces. But after doing some edits to the buffer and saving those spaces get deleted again (funny enough before-save-hook does not hold delete-trailing-whitespace anymore).

planigan commented 7 years ago

I've been struggling to figure out how to stop suppressing trailing whitespace in markdown in spacemacs. Turns out that I had set up editorconfig to do this before I found the option in the spacemacs config. I set dotspacemacs-whitespace-cleanup nil and am just letting editorconfig handle it now. The following basic ~/.editorconfig will clean up trailing whitespace everywhere other than markdown files if you add the editorconfig package in your config.

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
KMontag42 commented 6 years ago

I am still having this issue. Is there any update on it being fixed?

chshersh commented 6 years ago

I'm observing this issue as well. Toggling any of whitespace-cleanup hooks/actions/variables doesn't work. I'm editing code from another editor when I don't want to introduce whitespace changes.

treymerkley commented 4 years ago

can confirm this issue is still present.

usq commented 4 years ago

same issue here, have to switch to vim for whitespace changes :cry:

lestercheung commented 4 years ago

I've been struggling to figure out how to stop suppressing trailing whitespace in markdown in spacemacs. Turns out that I had set up editorconfig to do this before I found the option in the spacemacs config. I set dotspacemacs-whitespace-cleanup nil and am just letting editorconfig handle it now. The following basic ~/.editorconfig will clean up trailing whitespace everywhere other than markdown files if you add the editorconfig package in your config.

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

Came here to say this - It was editorconfig for me as well. :laughing:

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

GiovanH commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

I don't see any reason to think this issue has been fixed.

lebensterben commented 2 years ago

@GiovanH Is this still an issue on develop?

practicalli-johnny commented 2 years ago

I can confirm this issue on the latest commit of Spacemacs (as of today - 6ccbbcc7d develop origin/develop gnux: fix which-key prefix bug)

I add a whitespace at the end of a line in a yasnippet file I created. SPC SPC spacemacs/toggle-whitespace-cleanup SPC f s to save the file which then removes all whitespace from end of lines in the snippet buffer

The following seems to have no effect, as whitespace was still deleted

M-x eval-expression RET (remove-hook 'before-save-hook 'delete-trailing-whitespace) 
Spacemacs configuration SPC h d s #### System Info :computer: - OS: gnu/linux - Emacs: 27.1 - Spacemacs: 0.999.0 - Spacemacs branch: develop (rev. 6ccbbcc7d) - Graphic display: t - Distribution: spacemacs - Editing style: vim - Completion: helm - Layers: ```elisp (asciidoc (auto-completion :variables auto-completion-enable-help-tooltip t auto-completion-enable-snippets-in-popup t auto-completion-enable-sort-by-usage t auto-completion-use-company-box t) (clojure :variables cider-repl-display-help-banner nil cider-pprint-fn 'fipp clojure-indent-style 'align-arguments clojure-align-forms-automatically t clojure-toplevel-inside-comment-form t cider-overlays-use-font-lock t cider-repl-buffer-size-limit 100 clojure-enable-kaocha-runner t) colors command-log csv emacs-lisp emoji (git :variables git-magit-status-fullscreen t magit-diff-refine-hunk t git-enable-magit-todos-plugin t) github graphviz (helm :variables helm-follow-mode-persistent t) html javascript (json :variables js-indent-level 2 json-backend 'lsp) (lsp :variables lsp-enable-on-type-formatting t lsp-enable-indentation t lsp-enable-snippet nil lsp-enable-symbol-highlighting t lsp-ui-doc-enable t lsp-ui-doc-show-with-cursor nil lsp-ui-doc-show-with-mouse nil lsp-ui-doc-delay 1 lsp-ui-doc-include-signature t lsp-ui-sideline-enable nil lsp-ui-sideline-show-code-actions nil lsp-lens-enable t treemacs-space-between-root-nodes nil lsp-file-watch-threshold 10000 lsp-log-io nil) (markdown :variables markdown-live-preview-engine 'vmd) multiple-cursors (org :variables org-enable-github-support t org-enable-bootstrap-support t org-enable-reveal-js-support t org-want-todo-bindings t org-enable-org-journal-support t org-journal-dir "~/projects/journal/" org-journal-file-format "%Y-%m-%d" org-journal-date-prefix "#+TITLE: " org-journal-date-format "%A, %B %d %Y" org-journal-time-prefix "* " org-journal-time-format "" org-journal-carryover-items "TODO=\"TODO\"|TODO=\"DOING\"|TODO=\"BLOCKED\"|TODO=\"REVIEW\"") (ranger :variables ranger-show-preview t ranger-show-hidden t ranger-cleanup-eagerly t ranger-cleanup-on-disable t ranger-ignored-extensions '("mkv" "flv" "iso" "mp4")) (shell :variables shell-default-shell 'eshell shell-default-height 30 shell-default-position 'bottom) (spacemacs-layouts :variables spacemacs-layouts-restrict-spc-tab t persp-autokill-buffer-on-remove 'kill-weak) (spacemacs-modeline :variables doom-modeline-height 12 doom-modeline-major-mode-color-icon t doom-modeline-buffer-file-name-style 'relative-to-project doom-modeline-display-default-persp-name t doom-modeline-minor-modes nil doom-modeline-modal-icon nil) spell-checking (syntax-checking :variables syntax-checking-use-original-bitmaps t) (treemacs :variables treemacs-indentation 1 treemacs-use-git-mode 'simple) theming (unicode-fonts :variables unicode-fonts-enable-ligatures t unicode-fonts-ligature-modes '(prog-mode)) (version-control :variables version-control-diff-tool 'diff-hl version-control-global-margin t) yaml) ``` - System configuration features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON PDUMPER LCMS2 GMP
borup3 commented 2 years ago

How does this go unresolved for 5 years?

github-actions[bot] commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

dwang20151005 commented 4 months ago

nope still want this!

On Wed, May 1, 2024 at 12:36 PM github-actions[bot] < @.***> wrote:

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

— Reply to this email directly, view it on GitHub https://github.com/syl20bnr/spacemacs/issues/8221#issuecomment-2088737107, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSJX7DCXDVRXOYCADL4SP3ZAEKYLAVCNFSM4C5G6AXKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBYHA3TGNZRGA3Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

johbo commented 2 weeks ago

Just did bump into this as well I think. Did want to switch off the removal of trailing whitespace for a specific butter, but without success. My dotspacemacs-whitespace-cleanup is set to trailing.

In my case I've not found a way (yet) to disable the whitespace removal at all. Both spacemacs/toggle-gobal-whitespace-cleanup-off and spacemacs/toggle-whitespace-cleanup-off do not seem to have an effect.

fnussbaum commented 5 days ago

I will fix this.