comparison lisp/server.el @ 83172:1a136b47986d

Don't leave buffers created by nowait clients buried under others (rep. by Dan Nicolaescu). * lisp/server.el (server-process-filter): Select buffers opened by nowait clients, don't leave them buried under others. (Reported by Dan Nicolaescu.) (server-visit-files): Return list of buffers created. Update doc. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-212
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 10 Jul 2004 20:56:57 +0000
parents 69ebc75cb461
children e2567214221d
comparison
equal deleted inserted replaced
83171:09bbf2fc80da 83172:1a136b47986d
588 (server-client-get client 'environment))))) 588 (server-client-get client 'environment)))))
589 589
590 ;; Unknown command. 590 ;; Unknown command.
591 (t (error "Unknown command: %s" arg))))) 591 (t (error "Unknown command: %s" arg)))))
592 592
593 (when files 593 (let (buffers)
594 (run-hooks 'pre-command-hook) 594 (when files
595 (server-visit-files files client nowait) 595 (run-hooks 'pre-command-hook)
596 (run-hooks 'post-command-hook)) 596 (setq buffers (server-visit-files files client nowait))
597 597 (run-hooks 'post-command-hook))
598 ;; Delete the client if necessary. 598
599 (cond 599 ;; Delete the client if necessary.
600 (nowait 600 (cond
601 ;; Client requested nowait; return immediately. 601 (nowait
602 (server-log "Close nowait client" proc) 602 ;; Client requested nowait; return immediately.
603 (server-delete-client proc)) 603 (server-log "Close nowait client" proc)
604 ((and (not dontkill) 604 (server-delete-client proc))
605 (null (server-client-get client 'buffers))) 605 ((and (not dontkill) (null buffers))
606 ;; This client is empty; get rid of it immediately. 606 ;; This client is empty; get rid of it immediately.
607 (server-log "Close empty client" proc) 607 (server-log "Close empty client" proc)
608 (server-delete-client proc)) 608 (server-delete-client proc)))
609 (t 609 (cond
610 (let ((buffers (server-client-get client 'buffers))) 610 ((or isearch-mode (minibufferp))
611 (when buffers 611 nil)
612 ;; We visited some buffer for this client. 612 ((and frame (null buffers))
613 (cond 613 (message (substitute-command-keys
614 ((or isearch-mode (minibufferp)) 614 "When done with this frame, type \\[delete-frame]")))
615 nil) 615 ((not (null buffers))
616 ((and frame (null buffers)) 616 (server-switch-buffer (car buffers))
617 (message (substitute-command-keys 617 (run-hooks 'server-switch-hook)
618 "When done with this frame, type \\[delete-frame]"))) 618 (unless nowait
619 ((not (null buffers)) 619 (message (substitute-command-keys
620 (server-switch-buffer (car buffers)) 620 "When done with a buffer, type \\[server-edit]"))))))))
621 (run-hooks 'server-switch-hook)
622 (unless nowait
623 (message (substitute-command-keys
624 "When done with a buffer, type \\[server-edit]")))))))))))
625 621
626 ;; Save for later any partial line that remains. 622 ;; Save for later any partial line that remains.
627 (when (> (length string) 0) 623 (when (> (length string) 0)
628 (process-put proc 'previous-string string))) 624 (process-put proc 'previous-string string)))
629 ;; condition-case 625 ;; condition-case
639 (let ((column-number (nth 2 file-line-col))) 635 (let ((column-number (nth 2 file-line-col)))
640 (if (> column-number 0) 636 (if (> column-number 0)
641 (move-to-column (1- column-number))))) 637 (move-to-column (1- column-number)))))
642 638
643 (defun server-visit-files (files client &optional nowait) 639 (defun server-visit-files (files client &optional nowait)
644 "Find FILES and return the list CLIENT with the buffers nconc'd. 640 "Find FILES and return a list of buffers created.
645 FILES is an alist whose elements are (FILENAME LINENUMBER COLUMNNUMBER). 641 FILES is an alist whose elements are (FILENAME LINENUMBER COLUMNNUMBER).
646 NOWAIT non-nil means this client is not waiting for the results, 642 NOWAIT non-nil means this client is not waiting for the results,
647 so don't mark these buffers specially, just visit them normally." 643 so don't mark these buffers specially, just visit them normally."
648 ;; Bind last-nonmenu-event to force use of keyboard, not mouse, for queries. 644 ;; Bind last-nonmenu-event to force use of keyboard, not mouse, for queries.
649 (let ((last-nonmenu-event t) client-record) 645 (let ((last-nonmenu-event t) client-record)
674 (server-goto-line-column file) 670 (server-goto-line-column file)
675 (run-hooks 'server-visit-hook))) 671 (run-hooks 'server-visit-hook)))
676 (unless nowait 672 (unless nowait
677 ;; When the buffer is killed, inform the clients. 673 ;; When the buffer is killed, inform the clients.
678 (add-hook 'kill-buffer-hook 'server-kill-buffer nil t) 674 (add-hook 'kill-buffer-hook 'server-kill-buffer nil t)
679 (push (car client) server-buffer-clients) 675 (push (car client) server-buffer-clients))
680 (push (current-buffer) client-record)))) 676 (push (current-buffer) client-record)))
681 (server-client-set 677 (unless nowait
682 client 'buffers 678 (server-client-set
683 (nconc (server-client-get client 'buffers) client-record)))) 679 client 'buffers
680 (nconc (server-client-get client 'buffers) client-record)))
681 client-record))
684 682
685 (defun server-buffer-done (buffer &optional for-killing) 683 (defun server-buffer-done (buffer &optional for-killing)
686 "Mark BUFFER as \"done\" for its client(s). 684 "Mark BUFFER as \"done\" for its client(s).
687 This buries the buffer, then returns a list of the form (NEXT-BUFFER KILLED). 685 This buries the buffer, then returns a list of the form (NEXT-BUFFER KILLED).
688 NEXT-BUFFER is another server buffer, as a suggestion for what to select next, 686 NEXT-BUFFER is another server buffer, as a suggestion for what to select next,