emacs-helm / helm

Emacs incremental completion and selection narrowing framework
https://emacs-helm.github.io/helm/
GNU General Public License v3.0
3.36k stars 389 forks source link

Non-helm mode buffer is set to helm mode and the contents are wiped #1093

Closed gsingh93 closed 9 years ago

gsingh93 commented 9 years ago

This issue has been happening to me for over a month now, and it happens infrequently and is very hard to reproduce, but when it happens it sucks.

I was editing a buffer and hit C-x b to change buffers. The window split in half and a helm buffer opened. However, my original buffer was cleared and the mode was changed to Helm. The first time this happened to me I didn't notice and continued with switching buffers. I have emacs configured to save on each buffer change, so the blank buffer was then saved to my file, and the file was lost. I use version control, and due to a dumb default vc setting I didn't know at the time, no backup was created and my work was lost up until the last commit.

I am using emacs 24.5.1 on Arch Linux. Emacs tells me the version of Helm I'm using is 20150712.846, although this was happening with older versions. I'm using emacsclient if that's at all relevant. Let me know if you need any more information.

There is a chance that this is an emacs bug and not a helm bug, but it's hard to tell. It may happen any time any mode makes a new buffer, but because it doesn't happen every time, it's hard to confirm this.

thierryvolpiatto commented 9 years ago

Gulshan Singh notifications@github.com writes:

This issue has been happening to me for over a month now, and it happens infrequently and is very hard to reproduce, but when it happens it sucks.

I was editing a buffer and hit C-x b to change buffers. The window split in half and a helm buffer opened. However, my original buffer was cleared and the mode was changed to Helm. The first time this happened to me I didn't notice and continued with switching buffers. I have emacs configured to save on each buffer change,

I guess the problem comes from this configuration and is not related to helm. I hardly see how helm would alter the current-buffer otherwise.

so the blank buffer was then saved to my file, and the file was lost. I use version control, and due to a dumb vc setting, my work was lost up until the last commit.

I am using emacs 24.5.1 on Arch Linux.

Strange problems have been reported with emacs on arch linux, see https://github.com/emacs-helm/helm/issues/1000

Emacs tells me the version of Helm I'm using is 20150712.846, although this was happening with older versions. I'm using emacsclient if that's at all relevant. Let me know if you need any more information.

Try to start emacs with ./emacs-helm.sh during sometimes to see if the bug reappears.

Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997

gsingh93 commented 9 years ago

The only configuration I have for Helm is the default emacs prelude configuration, and some fuzzy search variables set to true.

It doesn't seem like the other Arch Linux problems are related.

I'll try to use emacs-helm.sh, but this is going to be tricky because it means I'll have to code for long periods of time without any of my normal configuration to try and reproduce this bug.

gsingh93 commented 9 years ago

In fact, a better idea might be for me to switch back to ido and smex for a while. For the year or so I used those modes I didn't have any problem, and I've only been using helm for two or three months, which is when this issue started happening. If I don't see the issue with ido or smex modes for a while, that means it's more likely this is a helm issue.

thierryvolpiatto commented 9 years ago

Gulshan Singh notifications@github.com writes:

In fact, a better idea might be for me to switch back to ido and smex for a while.

So don't expect your problem will be fixed if you don't help to fix it. I need more info, and i repeat, this bug is more likely due to your config and NOT to helm. More exactly in your config the part that save buffer at each change looks really bad and a strange idea.

For the year or so I used those modes I didn't have any problem, and I've only been using helm for two or three months, which is when this issue started happening. If I don't see the issue with ido or smex modes for a while, that means it's more likely this is a helm issue.

No. Ido and friends are using the minibuffer only and can't be compared to how helm works.

Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997

thierryvolpiatto commented 9 years ago

Gulshan Singh notifications@github.com writes:

The only configuration I have for Helm is the default emacs prelude configuration, and some fuzzy search variables set to true.

The problem doesn't come from the configuration of helm itself but from somewhere else, as I said in previous post, I guess it comes from your saving buffer at each change configuration.

I'll try to use emacs-helm.sh, but this is going to be tricky because it means I'll have to code for long periods of time without any of my normal configuration to try and reproduce this bug.

As you want, but if you don't give me more infos, I can't help you.

Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997

gsingh93 commented 9 years ago

Ok, I'll try to alternate between my regular emacs config and emacs-helm.sh for a while and see what happens.

The problem doesn't come from the configuration of helm itself but from somewhere else, as I said in previous post, I guess it comes from your saving buffer at each change configuration.

The only time saving on a buffer change would be a bad idea is if there is some bug with a mode that clears the buffer before it's changed. If that happens, it's the buggy mode that's to blame, not the saving configuration.

thierryvolpiatto commented 9 years ago

Gulshan Singh notifications@github.com writes:

The only time saving on a buffer change would be a bad idea is if there is some bug with a mode that clears the buffer before it's changed.

Helm is NOT clearing your buffer, never.

If that happens, it's the buggy mode that's to blame, not the saving configuration.

If you think helm is a buggy mode, use something else.

If your saving configuration use hooks, these hooks will run when you use helm or whatever.

Please send here your save buffer configuration.

Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997

gsingh93 commented 9 years ago

Here is the configuration: https://github.com/bbatsov/prelude/blob/master/core/prelude-editor.el#L172

It is part of emacs prelude, and is being used by thousands of users without any issues.

If you think helm is a buggy mode, use something else.

I'm not saying it is, I'm trying to find out what is buggy here, because something definitely is. I highly doubt it's the saving configuration. I also don't really like your tone here, I'm not trying to offend you or insult helm-mode here.

thierryvolpiatto commented 9 years ago

Gulshan Singh notifications@github.com writes:

Here is the configuration: https://github.com/bbatsov/prelude/blob/master/core/prelude-editor.el#L172

Yes here is the problem, this code is not safe enough IMO. Try to disable this and helm should work correctly. You have to understand that it is not up to me to fix code of prelude and/or advises of users generally. My goal is to make helm working starting from emacs -Q, i.e with emacs-helm.sh.

So please report the bug to prelude because it is not reproductible here.

It is part of emacs prelude, and is being used by thousands of users without any issues.

And you are the first to report this so maybe there is something wrong with your config with or without prelude I don't know.

If you think helm is a buggy mode, use something else.

I'm not saying it is, I'm trying to find out what is buggy here, because something definitely is. I highly doubt it's the saving configuration.

So I need more infos, backtrace or whatever, I can do nothing on my side as I can't reproduce, sorry.

I also don't really like your tone here, I'm not trying to offend you or insult helm-mode here.

It was my feeling.

Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997

gsingh93 commented 9 years ago

Yes here is the problem, this code is not safe enough IMO.

Can you explain why this code isn't safe? It seems fine to me and without an explanation and can't be sure this is the problem and I can't explain to the prelude developers what the issue is.

thierryvolpiatto commented 9 years ago

Gulshan Singh notifications@github.com writes:

Yes here is the problem, this code is not safe enough IMO.

Can you explain why this code isn't safe?

Not yet, I have to read the code more carefully, I have just downloaded the code now.

I see there is a variable to disable this:

prelude-auto-save

Please disable this and try to see if the problem persist.

But as I said you should try to reproduce the problem with ./emacs-helm.sh.

Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997

thierryvolpiatto commented 9 years ago

Gulshan Singh notifications@github.com writes:

It seems fine to me

Even if I don't like at all these advices, I indeed don't see what could be wrong.

On the helm side I don't see what could erase a buffer (when helm erase its buffer to update the code run always in with-current-buffer.

What other packages are you using ? (just give the value of `package-selected-packages')

What else do you have in your init file ? (any chance to see it ?)

Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997

gsingh93 commented 9 years ago

I don't have the package-selected-packages variable, but I have package-activated-list in case that's helpful:

(ace-jump-buffer dash ace-jump-mode ace-jump-mode ace-window avy anzu avy browse-kill-ring command-log-mode company-anaconda anaconda-mode f dash s dash json-rpc company diff-hl diminish discover-my-major makey easy-kill elisp-slime-nav expand-region f dash s flx-ido flx flycheck-rust dash flycheck let-alist pkg-info epl dash geiser gist gh logito pcache git-commit-mode git-rebase-mode git-timemachine gitconfig-mode gitignore-mode glsl-mode god-mode grizzl guru-mode haskell-mode helm-ag helm async helm-descbinds helm async helm-projectile dash projectile pkg-info epl dash helm async ido-ubiquitous ido-completing-read+ js2-mode json-rpc let-alist logito magit magit-popup dash git-commit with-editor dash dash with-editor dash dash magit-popup dash makey markdown-mode move-text operate-on-number osc ov pcache pkgbuild-mode projectile pkg-info epl dash rainbow-delimiters rainbow-mode rust-mode s scss-mode smartparens dash smartrep smex ssh-config-mode syntax-subword systemd thrift toml-mode tss yaxception log4e json-mode json-snatcher json-reformat auto-complete popup unbound undo-tree volatile-highlights web-mode with-editor dash yaml-mode yasnippet yaxception zenburn-theme zop-to-char)

My configuration is the stock prelude configuration with the following extra configuration:

(eval-after-load 'flycheck
  '(add-hook 'flycheck-mode-hook #'flycheck-rust-setup))

(setq vc-make-backup-files t)
(setq vc-handled-backends nil)

; Preserve case in completions
(set 'company-dabbrev-downcase nil)

(setq racer-rust-src-path "~/code/lang/rust/rust/src/")
(setq racer-cmd "~/code/lang/rust/racer/target/release/racer")
(add-to-list 'load-path "~/code/lang/rust/racer/editors/emacs")
(eval-after-load "rust-mode" '(require 'racer))

(require 'rust-mode)
(define-key rust-mode-map (kbd "M-.") #'racer-find-definition)

; see https://emacs.stackexchange.com/questions/3798/how-do-i-make-pressing-ret-in-helm-find-files-open-the-directory
(require 'helm)
(defun fu/helm-find-files-navigate-forward (orig-fun &rest args)
  (if (file-directory-p (helm-get-selection))
      (apply orig-fun args)
    (helm-maybe-exit-minibuffer)))
(advice-add 'helm-execute-persistent-action :around #'fu/helm-find-files-navigate-forward)
(define-key helm-find-files-map (kbd "<return>") 'helm-execute-persistent-action)

(setq helm-apropos-fuzzy-match t)
(setq helm-buffer-fuzzy-match t)
(setq helm-M-x-fuzzy-match t)
(setq helm-recentf-fuzzy-match t)

(set-frame-parameter (selected-frame) 'alpha '(75 85))
(add-to-list 'default-frame-alist '(alpha 85 85))
(load-theme 'wheatgrass)

(autoload 'extempore-mode "extempore" "Extempore mode" t)
(add-to-list 'auto-mode-alist '("\\.xtm\\'" . extempore-mode))

(add-hook 'server-done-hook 'recentf-save-list)

(setq prelude-guru nil)

(setq auto-mode-alist (cons '("\\.m$" . octave-mode) auto-mode-alist))
(add-hook 'rust-mode-hook '(lambda () (set-variable 'whitespace-line-column 99)))

(add-hook 'haskell-mode-hook 'interactive-haskell-mode)

(require 'syntax-subword)
(global-syntax-subword-mode)

; Recentf ignore list
(add-to-list 'recentf-exclude "/.git/COMMIT_EDITMSG")
(add-to-list 'recentf-exclude "/.emacs.d/elpa/")
(add-to-list 'recentf-exclude "ido.hist\\'")

; No indent in namespaces
(defconst namespace-no-indent-style
  '("cc-mode"
    (c-offsets-alist . ((innamespace . [0])))))

(c-add-style "namespace-no-indent-style" namespace-no-indent-style)
thierryvolpiatto commented 9 years ago

Gulshan Singh notifications@github.com writes:

I don't have the package-selected-packages variable, but I have package-activated-list in case that's helpful:

My configuration is the stock prelude configuration with the following extra configuration:

Hmm, I see nothing wrong in your extra configuration, but you have so many different packages...

The best you have to do is to look carefully next time your bug happen the conditions where you are to be able to reproduce at each time and provide a recipe.

With the recipe you will be able to check if it is reproductible with only helm enabled.

My impression is that something modify your buffer when the window configuration change (e.g delete buffer contents, reinsert the content of buffer with something different (what?), save...), possibly in window-configuration-change-hook or something like that.

All what I can say is helm is not doing something like this in the helm-current-buffer, at the contrary all is preserved here when helm is running.

Ah also, is the buffer you are editing a remote buffer ? (In this case it would be a bug with 'tramp+the prelude save-buffer advices')

Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997