pinkas@cadev4.intel.com (Israel Pinkas ~) (04/27/88)
In server.el, as distributed, the following code (in 18.48 and 18.50) exists in start-server: ;; kill it dead! (if server-process (progn (set-process-sentinel server-process nil) (condition-case () (delete-process server-process) (error nil)))) (condition-case () (delete-file "~/.emacs_server") (error nil)) As distributed, the server process exits when the server socket already exists. condition-case is documented as follows: condition-case: Regain control when an error is signaled. (condition-case VAR BODYFORM HANDLERS...) executes BODYFORM and returns its value if no error happens. Each element of HANDLERS looks like (CONDITION-NAME BODY...) where the BODY is made of Lisp expressions. The handler is applicable to an error if CONDITION-NAME is one of the error's condition names. When a handler handles an error, control returns to the condition-case and the handler BODY... is executed with VAR bound to (SIGNALED-CONDITIONS . SIGNAL-DATA). The value of the last BODY form is returned from the condition-case. See SIGNAL for more info. My understanding is that the first argument to condition-case should be a variable, which () isn't. When I replace the () with i in the delete-file line, the server process does not die upon startup. So... Is there any reason that () was used? Or is it a simple typo? If so, could somebody make sure that it gets into future releases? Alternately, since nothing is being done when an a signal (error) occurs, is there a better function to use? Something that will simplely ignore the error resulting from the file not being existent? -Israel -------------------------------------- Disclaimer: The above are my personal opinions, and in no way represent the opinions of Intel Corporation. In no way should the above be taken to be a statement of Intel. UUCP: {amdcad,decwrl,hplabs,oliveb,pur-ee,qantel}!intelca!mipos3!cadev4!pinkas ARPA: pinkas%cadev4.intel.com@relay.cs.net CSNET: pinkas%cadev4.intel.com
nate@mipos3.intel.com (Nate Hess) (04/28/88)
In article <2112@mipos3.intel.com> pinkas@cadev4.UUCP () writes: >In server.el, as distributed, the following code (in 18.48 and 18.50) >exists in start-server: > ;; kill it dead! > (if server-process > (progn > (set-process-sentinel server-process nil) > (condition-case () (delete-process server-process) (error nil)))) > (condition-case () (delete-file "~/.emacs_server") (error nil)) [ Israel gives the documentation string for condition-case, noting that the first argument is supposed to be a variable. (I think there is a bug in the documentation, since VAR is never mentioned again after (condition-case VAR BODYFORM HANDLERS...)) He gives a fix which substitutes i for (). He then continues...] >Alternately, since nothing is being done when an a signal (error) occurs, >is there a better function to use? Something that will simplely ignore the >error resulting from the file not being existent? Yes, I believe that there is a better function: file-exists-p, which does the appropriate lispy thing. So, the code I wrote to replace the last line from above is: (if (file-exists-p "~/.emacs_server") (delete-file "~/.emacs_server")) or, if you're using the code Israel posted earlier to get around the problem of .emacs_server being in the home directory: (if (file-exists-p (concat "/tmp/.emacs_server_" (user-real-login))) (delete-file (concat "/tmp/.emacs_server_" (user-real-login)))) At your serverice, --woodstock -- "How did you get your mind to tilt like your hat?" ...!{decwrl|hplabs!oliveb|pur-ee|qantel|amd}!intelca!mipos3!nate <domainish> : nate@mipos3.intel.com ATT : (408) 765-4309
nate@mipos3.intel.com (Nate Hess) (04/28/88)
In article <2123@mipos3.intel.com> I write: >(if (file-exists-p (concat "/tmp/.emacs_server_" (user-real-login))) > (delete-file (concat "/tmp/.emacs_server_" (user-real-login)))) Argh! (replace-string "user-real-login" "user-real-login-name") That's what I get for not using 'lisp-complete-symbol' when typing in code... :-)# --woodstock -- "How did you get your mind to tilt like your hat?" ...!{decwrl|hplabs!oliveb|pur-ee|qantel|amd}!intelca!mipos3!nate <domainish> : nate@mipos3.intel.com ATT : (408) 765-4309
trost@reed.UUCP (Trost [no first name]) (04/29/88)
In article <2112@mipos3.intel.com> pinkas@cadev4.UUCP () writes: >In server.el, as distributed, the following code (in 18.48 and 18.50) >exists in start-server: > > ;; kill it dead! > (if server-process > (progn > (set-process-sentinel server-process nil) > (condition-case () (delete-process server-process) (error nil)))) > (condition-case () (delete-file "~/.emacs_server") (error nil)) > >As distributed, the server process exits when the server socket already >exists. condition-case is documented as follows: What? No it doesn't; it takes over, but read on... >My understanding is that the first argument to condition-case should be a >variable, which () isn't. When I replace the () with i in the delete-file >line, the server process does not die upon startup. > >Alternately, since nothing is being done when an a signal (error) occurs, >is there a better function to use? Something that will simplely ignore the >error resulting from the file not being existent? The () (usually seen as "nil") in the condition case probably tells emacs to not to bother with assigning the data to any variable. This is OK here because the data isn't used at all. As for leaving out the condition case, that is a bad thing. The (error nil) clause at the end tells emacs to ignore the error altogether; otherwise, if the bodyform within the command failed, it would stop right there with an error. Now, someone can tell me how to use "signal" correctly, right? I've played with it a bit, and it doesn't seem to do what's desired; it always complains about "peculiar errors". I've wanted to try my hand with programming using exceptions, and this seems like a good way to try it out. -- ...!(ogcvax|tektronix)!reed!trost (UUCP) When in danger, when in doubt, run in circles, scream and shout, gnash your teeth and cry and pout, when in danger, when in doubt.