Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] app-editors/emacs-24.1-r1 not saving files
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
njuk-njuk
n00b
n00b


Joined: 24 Aug 2003
Posts: 65
Location: New York, NY

PostPosted: Sun Sep 09, 2012 5:50 pm    Post subject: [solved] app-editors/emacs-24.1-r1 not saving files Reply with quote

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
View user's profile Send private message
roravun
Tux's lil' helper
Tux's lil' helper


Joined: 05 Sep 2012
Posts: 82

PostPosted: Sun Sep 09, 2012 10:07 pm    Post subject: Reply with quote

`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
View user's profile Send private message
njuk-njuk
n00b
n00b


Joined: 24 Aug 2003
Posts: 65
Location: New York, NY

PostPosted: Mon Sep 10, 2012 12:46 am    Post subject: Reply with quote

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
View user's profile Send private message
roravun
Tux's lil' helper
Tux's lil' helper


Joined: 05 Sep 2012
Posts: 82

PostPosted: Mon Sep 10, 2012 9:46 am    Post subject: Reply with quote

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
View user's profile Send private message
njuk-njuk
n00b
n00b


Joined: 24 Aug 2003
Posts: 65
Location: New York, NY

PostPosted: Mon Sep 10, 2012 1:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Mon Sep 10, 2012 2:36 pm    Post subject: Reply with quote

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 :wink:

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
View user's profile Send private message
njuk-njuk
n00b
n00b


Joined: 24 Aug 2003
Posts: 65
Location: New York, NY

PostPosted: Tue Sep 11, 2012 8:50 pm    Post subject: [solved] app-editors/emacs-24.1-r1 not saving files Reply with quote

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
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Wed Sep 12, 2012 1:45 pm    Post subject: Re: [solved] app-editors/emacs-24.1-r1 not saving files Reply with quote

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
View user's profile Send private message
njuk-njuk
n00b
n00b


Joined: 24 Aug 2003
Posts: 65
Location: New York, NY

PostPosted: Wed Sep 12, 2012 9:18 pm    Post subject: Re: [solved] app-editors/emacs-24.1-r1 not saving files Reply with quote

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
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Thu Sep 13, 2012 6:21 am    Post subject: Re: [solved] app-editors/emacs-24.1-r1 not saving files Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum