aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2019-11-07 19:11:23 +0200
committerEli Zaretskii2019-11-07 19:11:23 +0200
commite06324a032e9248cb9bce0e40077a726cc4ea719 (patch)
tree0a42513e376cf363481c507ee3631a8824eae83d
parent1b715834c3de2231fd602f43530d04f710281451 (diff)
downloademacs-e06324a032e9248cb9bce0e40077a726cc4ea719.tar.gz
emacs-e06324a032e9248cb9bce0e40077a726cc4ea719.zip
Revert "Don't flash previous buffer when connecting with emacsclient"
This reverts commit 49fc040077b33bd1e78ee425575e76329b772a41. It turns out that the fix for a minor aesthetical annoyance caused much more serious bugs: bug#31038, bug#35726, Bug#37097,
-rw-r--r--lisp/server.el89
1 files changed, 39 insertions, 50 deletions
diff --git a/lisp/server.el b/lisp/server.el
index 45fa55ad6b0..14114c8b3aa 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1098,8 +1098,7 @@ The following commands are accepted by the client:
1098 tty-type ; string. 1098 tty-type ; string.
1099 files 1099 files
1100 filepos 1100 filepos
1101 args-left 1101 args-left)
1102 create-frame-func)
1103 ;; Remove this line from STRING. 1102 ;; Remove this line from STRING.
1104 (setq string (substring string (match-end 0))) 1103 (setq string (substring string (match-end 0)))
1105 (setq args-left 1104 (setq args-left
@@ -1251,29 +1250,28 @@ The following commands are accepted by the client:
1251 (or files commands) 1250 (or files commands)
1252 (setq use-current-frame t)) 1251 (setq use-current-frame t))
1253 1252
1254 (setq create-frame-func 1253 (setq frame
1255 (lambda () 1254 (cond
1256 (cond 1255 ((and use-current-frame
1257 ((and use-current-frame 1256 (or (eq use-current-frame 'always)
1258 (or (eq use-current-frame 'always) 1257 ;; We can't use the Emacs daemon's
1259 ;; We can't use the Emacs daemon's 1258 ;; terminal frame.
1260 ;; terminal frame. 1259 (not (and (daemonp)
1261 (not (and (daemonp) 1260 (null (cdr (frame-list)))
1262 (null (cdr (frame-list))) 1261 (eq (selected-frame)
1263 (eq (selected-frame) 1262 terminal-frame)))))
1264 terminal-frame))))) 1263 (setq tty-name nil tty-type nil)
1265 (setq tty-name nil tty-type nil) 1264 (if display (server-select-display display)))
1266 (if display (server-select-display display))) 1265 ((or (and (eq system-type 'windows-nt)
1267 ((or (and (eq system-type 'windows-nt) 1266 (daemonp)
1268 (daemonp) 1267 (setq display "w32"))
1269 (setq display "w32")) 1268 (eq tty-name 'window-system))
1270 (eq tty-name 'window-system)) 1269 (server-create-window-system-frame display nowait proc
1271 (server-create-window-system-frame display nowait proc 1270 parent-id
1272 parent-id 1271 frame-parameters))
1273 frame-parameters)) 1272 ;; When resuming on a tty, tty-name is nil.
1274 ;; When resuming on a tty, tty-name is nil. 1273 (tty-name
1275 (tty-name 1274 (server-create-tty-frame tty-name tty-type proc))))
1276 (server-create-tty-frame tty-name tty-type proc)))))
1277 1275
1278 (process-put 1276 (process-put
1279 proc 'continuation 1277 proc 'continuation
@@ -1285,7 +1283,7 @@ The following commands are accepted by the client:
1285 (if (and dir (file-directory-p dir)) 1283 (if (and dir (file-directory-p dir))
1286 dir default-directory))) 1284 dir default-directory)))
1287 (server-execute proc files nowait commands 1285 (server-execute proc files nowait commands
1288 dontkill create-frame-func tty-name))))) 1286 dontkill frame tty-name)))))
1289 1287
1290 (when (or frame files) 1288 (when (or frame files)
1291 (server-goto-toplevel proc)) 1289 (server-goto-toplevel proc))
@@ -1294,7 +1292,7 @@ The following commands are accepted by the client:
1294 ;; condition-case 1292 ;; condition-case
1295 (t (server-return-error proc err)))) 1293 (t (server-return-error proc err))))
1296 1294
1297(defun server-execute (proc files nowait commands dontkill create-frame-func tty-name) 1295(defun server-execute (proc files nowait commands dontkill frame tty-name)
1298 ;; This is run from timers and process-filters, i.e. "asynchronously". 1296 ;; This is run from timers and process-filters, i.e. "asynchronously".
1299 ;; But w.r.t the user, this is not really asynchronous since the timer 1297 ;; But w.r.t the user, this is not really asynchronous since the timer
1300 ;; is run after 0s and the process-filter is run in response to the 1298 ;; is run after 0s and the process-filter is run in response to the
@@ -1304,29 +1302,20 @@ The following commands are accepted by the client:
1304 ;; including code that needs to wait. 1302 ;; including code that needs to wait.
1305 (with-local-quit 1303 (with-local-quit
1306 (condition-case err 1304 (condition-case err
1307 (let* ((buffers (server-visit-files files proc nowait)) 1305 (let ((buffers (server-visit-files files proc nowait)))
1308 ;; If we were told only to open a new client, obey 1306 (mapc 'funcall (nreverse commands))
1309 ;; `initial-buffer-choice' if it specifies a file 1307 ;; If we were told only to open a new client, obey
1310 ;; or a function. 1308 ;; `initial-buffer-choice' if it specifies a file
1311 (initial-buffer (unless (or files commands) 1309 ;; or a function.
1312 (let ((buf 1310 (unless (or files commands)
1313 (cond ((stringp initial-buffer-choice) 1311 (let ((buf
1314 (find-file-noselect initial-buffer-choice)) 1312 (cond ((stringp initial-buffer-choice)
1315 ((functionp initial-buffer-choice) 1313 (find-file-noselect initial-buffer-choice))
1316 (funcall initial-buffer-choice))))) 1314 ((functionp initial-buffer-choice)
1317 (if (buffer-live-p buf) buf (startup--get-buffer-create-scratch))))) 1315 (funcall initial-buffer-choice)))))
1318 ;; Set current buffer so that newly created tty frames 1316 (switch-to-buffer
1319 ;; show the correct buffer initially. 1317 (if (buffer-live-p buf) buf (get-buffer-create "*scratch*"))
1320 (frame (with-current-buffer (or (car buffers) 1318 'norecord)))
1321 initial-buffer
1322 (current-buffer))
1323 (prog1
1324 (funcall create-frame-func)
1325 ;; Switch to initial buffer in case the frame was reused.
1326 (when initial-buffer
1327 (switch-to-buffer initial-buffer 'norecord))))))
1328
1329 (mapc #'funcall (nreverse commands))
1330 1319
1331 ;; Delete the client if necessary. 1320 ;; Delete the client if necessary.
1332 (cond 1321 (cond