Browse Source

Style fixes.

Two misindented line, one use of ";" that should be ";;", a couple of
`if's that are better written as `when's, missing space, typo, avoid
calling `get-buffer' with "".
Eli Barzilay 11 years ago
parent
commit
bbb0df7991
1 changed files with 25 additions and 24 deletions
  1. 25 24
      edit-server.el

+ 25 - 24
edit-server.el

@@ -60,9 +60,9 @@
 ;; example:
 ;; example:
 ;;
 ;;
 ;; (add-hook 'edit-server-start-hook
 ;; (add-hook 'edit-server-start-hook
-;;          (lambda ()
-;;            (when (string-match "github.com" (buffer-name))
-;;              (markdown-mode))))
+;;           (lambda ()
+;;             (when (string-match "github.com" (buffer-name))
+;;               (markdown-mode))))
 
 
 
 
 ;;; Code:
 ;;; Code:
@@ -322,7 +322,7 @@ will cause it to be verbose."
       (message "An edit-server process is already running")
       (message "An edit-server process is already running")
     (ad-activate 'save-buffers-kill-emacs)
     (ad-activate 'save-buffers-kill-emacs)
     (setq edit-server-clients '())
     (setq edit-server-clients '())
-    (if verbose (get-buffer-create edit-server-log-buffer-name))
+    (when verbose (get-buffer-create edit-server-log-buffer-name))
     (edit-server-log nil "Created a new edit-server process")))
     (edit-server-log nil "Created a new edit-server process")))
 
 
 (defun edit-server-stop nil
 (defun edit-server-stop nil
@@ -347,20 +347,20 @@ will cause it to be verbose."
 This is done for logging purposes.  If `edit-server-verbose' is
 This is done for logging purposes.  If `edit-server-verbose' is
 non-nil, then STRING is also echoed to the message line."
 non-nil, then STRING is also echoed to the message line."
   (let ((string (apply 'format fmt args)))
   (let ((string (apply 'format fmt args)))
-    (if edit-server-verbose
-	(message string))
-    (if (get-buffer edit-server-log-buffer-name)
-	(with-current-buffer edit-server-log-buffer-name
-	  (goto-char (point-max))
-	  (insert (current-time-string)
-		  " "
-		  (if (processp proc)
-		      (concat
-		       (buffer-name (process-buffer proc))
-		       ": ")
-		    "") ; nil is not acceptable to 'insert
-		  string)
-	  (or (bolp) (newline))))))
+    (when edit-server-verbose
+      (message string))
+    (when (get-buffer edit-server-log-buffer-name)
+      (with-current-buffer edit-server-log-buffer-name
+	(goto-char (point-max))
+	(insert (current-time-string)
+		" "
+		(if (processp proc)
+		    (concat
+		     (buffer-name (process-buffer proc))
+		     ": ")
+		  "") ; nil is not acceptable to 'insert
+		string)
+	(or (bolp) (newline))))))
 
 
 (defun edit-server-accept (server client msg)
 (defun edit-server-accept (server client msg)
   "Accept a new client connection."
   "Accept a new client connection."
@@ -514,13 +514,14 @@ to `edit-server-default-major-mode'"
     (when mode
     (when mode
       (funcall mode))))
       (funcall mode))))
 
 
-(defun edit-server-find-or-create-edit-buffer(proc &optional existing)
+(defun edit-server-find-or-create-edit-buffer (proc &optional existing)
   "Find and existing or create an new edit buffer, place content in it
   "Find and existing or create an new edit buffer, place content in it
 and save the network process for the final call back"
 and save the network process for the final call back"
-  (let* ((existing-buffer (get-buffer (or (and (stringp existing) existing) "")))
+  ;; FIXME: `existing' is useless: see issue #104.
+  (let* ((existing-buffer (and (stringp existing) (get-buffer existing)))
 	 (buffer (or existing-buffer (generate-new-buffer
 	 (buffer (or existing-buffer (generate-new-buffer
-				     (or edit-server-url
-					 edit-server-edit-buffer-name)))))
+				      (or edit-server-url
+					  edit-server-edit-buffer-name)))))
 
 
     (edit-server-log proc
     (edit-server-log proc
 		     "using buffer %s for edit (existing-buffer is %s)"
 		     "using buffer %s for edit (existing-buffer is %s)"
@@ -534,7 +535,7 @@ and save the network process for the final call back"
     ;; I seem to be working around a bug here :-/
     ;; I seem to be working around a bug here :-/
     ;;
     ;;
     ;; For some reason the copy-to-buffer doesn't blat the existing contents.
     ;; For some reason the copy-to-buffer doesn't blat the existing contents.
-    ;; This screws up formatting as the contents where decoded before being
+    ;; This screws up formatting as the contents were decoded before being
     ;; sent back to the browser. As a kludge I save the returned contents
     ;; sent back to the browser. As a kludge I save the returned contents
     ;; in the kill-ring.
     ;; in the kill-ring.
     (when existing-buffer
     (when existing-buffer
@@ -638,7 +639,7 @@ When called interactively, use prefix arg to abort editing."
 	(delete-frame edit-server-frame))
 	(delete-frame edit-server-frame))
       ;; delete-frame may change the current buffer
       ;; delete-frame may change the current buffer
       (unless nokill
       (unless nokill
-        ; don't run abort twice in a row.
+        ;; don't run abort twice in a row.
         (remove-hook 'kill-buffer-hook 'edit-server-abort*)
         (remove-hook 'kill-buffer-hook 'edit-server-abort*)
 	(kill-buffer buffer))
 	(kill-buffer buffer))
       (edit-server-kill-client proc))))
       (edit-server-kill-client proc))))