View previous topic :: View next topic |
Author |
Message |
njuk-njuk n00b
Joined: 24 Aug 2003 Posts: 65 Location: New York, NY
|
Posted: Sun Sep 09, 2012 5:50 pm Post subject: [solved] app-editors/emacs-24.1-r1 not saving files |
|
|
i just updated my system, which moved me from emacs-23.4 to emacs-24.1. i can run emacs (and emacsclient) without issue, but i am unable to save any files.
when i execute 'save-buffer', the minibuffer properly displays "Saving file /path/to/file..." but nothing else happens. the file is not saved. the status of the buffer is still '**' (modified). there are no notable messages in the *Messages* buffer.
i've never run across something like this. anyone have any ideas on how to troubleshoot this?
thanks.
Last edited by njuk-njuk on Tue Sep 11, 2012 8:57 pm; edited 1 time in total |
|
Back to top |
|
|
roravun Tux's lil' helper
Joined: 05 Sep 2012 Posts: 82
|
Posted: Sun Sep 09, 2012 10:07 pm Post subject: |
|
|
`M-x ielm' will drop you into elisp shell.
Then type '(write-file "./whatswrongemacs")' and see what happens. The command should visit the file, and automatically save the buffer. Hopefully it will dump some useful info if in trouble. |
|
Back to top |
|
|
njuk-njuk n00b
Joined: 24 Aug 2003 Posts: 65 Location: New York, NY
|
Posted: Mon Sep 10, 2012 12:46 am Post subject: |
|
|
roravun wrote: | `M-x ielm' will drop you into elisp shell.
Then type '(write-file "./whatswrongemacs")' and see what happens. The command should visit the file, and automatically save the buffer. Hopefully it will dump some useful info if in trouble. |
thanks for the suggestion. after i typed in the above and hit <enter> was "nil" as a result of executing the command --- i assume i wasn't supposed to include the single quotes ('). so, nothing useful it seems. |
|
Back to top |
|
|
roravun Tux's lil' helper
Joined: 05 Sep 2012 Posts: 82
|
Posted: Mon Sep 10, 2012 9:46 am Post subject: |
|
|
Yes, you werent supposed to type single quotes. In Lisp we prefix symbols with " ' ".
It is ok that the function returned nil. In the minibuffer you should see "Wrote ./whatswrongemacs" if it succeded. And the file should appear in your current directory.
The command used to save buffers is (save-buffer). If you still does not see any useful messages I think you should file a bug against emacs. I have no clue what might be the cause of this strange behaviour. Although if you have customized your emacs, you should try to save buffer without any .emacs file loaded at all, preferably as a different user. |
|
Back to top |
|
|
njuk-njuk n00b
Joined: 24 Aug 2003 Posts: 65 Location: New York, NY
|
Posted: Mon Sep 10, 2012 1:31 pm Post subject: |
|
|
roravun wrote: | [...] Although if you have customized your emacs, you should try to save buffer without any .emacs file loaded at all, preferably as a different user. |
i don't know why i didn't think of this. guess i was so caught off-guard by the odd behavior. i switched over to a user that doesn't have a .emacs file, and everything worked fine; both (save-buffer) and (write-file) executed properly. i tracked down the offending bit in my .emacs file, but am unsure what is wrong as i've had this is a piece of code for years --- it gets called through 'write-file-hooks.
if i remove the 'if' statement, everything works fine; however, with it in, then the buggy behavior exists. everything else in my .emacs file seems to be fine --- in respect to this (save-buffer) issue --- except this 'if' statement that is part of this function.
Code: |
(defun untabify-buffer ()
"Converts tabs to spaces in all buffers except Makefiles and calendar files."
(interactive)
(if (not
(or (eq major-mode 'makefile-mode)
(eq major-mode 'makefile-bsdmake-mode)
(eq major-mode 'makefile-gmake-mode)
(string= (file-name-nondirectory (buffer-file-name)) "calendar")))
(untabify (point-min) (point-max))
(when (interactive-p)
(message "Makefile and calendar buffers will not be untabified.")
(ding t))))
|
|
|
Back to top |
|
|
mv Watchman
Joined: 20 Apr 2005 Posts: 6747
|
Posted: Mon Sep 10, 2012 2:36 pm Post subject: |
|
|
Please note anyway:
write-file-hooks wrote: | This variable is an alias for `write-file-functions'.
This variable is obsolete since 22.1 |
Of course, this was not your question. To answer your question:
write-file-hooks wrote: | List of functions to be called before writing out a buffer to a file.
If one of them returns non-nil, the file is considered already written
and the rest are not called. |
Now it happens in lisp that (if ...) returns nil if the condition fails and there is no else-part. So if your "if"-condition does not apply it has the side effect that your file is not written. Lisp always gives you a fun time through side effects
Edit: I misread "non-nil" as "nil", i.e. the trouble occurs if the conditional applies. Anyway, this does not change my argument much: You must return a well-defined value independent of the test. |
|
Back to top |
|
|
njuk-njuk n00b
Joined: 24 Aug 2003 Posts: 65 Location: New York, NY
|
Posted: Tue Sep 11, 2012 8:50 pm Post subject: [solved] app-editors/emacs-24.1-r1 not saving files |
|
|
thanks, mv, for pointing in the right direction. it is odd that this behavior never reared its head before 24.1. basically, (untabify (point-min) (point-max)) returns 0 upon completion, which is non-nil. to get around this, i simply prepended (not) to force nil. not sure this is an elegant solution; though i've been using emacs for almost 30 years, i'm basically a novice with elisp.
Code: | (not (untabify (point-min) (point-max)))
|
|
|
Back to top |
|
|
mv Watchman
Joined: 20 Apr 2005 Posts: 6747
|
Posted: Wed Sep 12, 2012 1:45 pm Post subject: Re: [solved] app-editors/emacs-24.1-r1 not saving files |
|
|
I don't think this is what you want. For simplicity, I would put the whole thing into (progn ... nil). (Not programmed lisp for a long time - not sure about the syntax.) |
|
Back to top |
|
|
njuk-njuk n00b
Joined: 24 Aug 2003 Posts: 65 Location: New York, NY
|
Posted: Wed Sep 12, 2012 9:18 pm Post subject: Re: [solved] app-editors/emacs-24.1-r1 not saving files |
|
|
mv wrote: | I don't think this is what you want. For simplicity, I would put the whole thing into (progn ... nil). (Not programmed lisp for a long time - not sure about the syntax.) |
i had seen (progn) when skimming the elisp manual, and it seemed like the a valid approach, but i didn't have time to investigate. it actually works perfectly well and seems much more appropriate than my poor use of (not).
Code: | (progn
(untabify (point-min) (point-max))
nil)
|
thanks again, mv, for the help in getting this solved. it's really a bugger when one's editor can't save anything. no longer a problem now. |
|
Back to top |
|
|
mv Watchman
Joined: 20 Apr 2005 Posts: 6747
|
Posted: Thu Sep 13, 2012 6:21 am Post subject: Re: [solved] app-editors/emacs-24.1-r1 not saving files |
|
|
I meant actually to put the whole expression into this construct: As it is now, also the "else" part might cause troubles. Alternativeily, you can in addtion put "nil" at the end of the else-part, since IIRC the else-part has an implicit "progn"). |
|
Back to top |
|
|
|