From bd1773a856760662c86cd5e160ccd05a787eb9a4 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Wed, 21 Apr 2010 03:34:08 +0300 Subject: [PATCH] Add command line switch `--tabs' to open files in new tabs. Display startup screen in a separate tab. --- lisp/startup.el | 23 ++++++++++++++++++----- src/emacs.c | 2 ++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lisp/startup.el b/lisp/startup.el index e8a6dc3dbb5..7891b112035 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -2079,6 +2079,7 @@ A fancy display is used on graphic displays, normal otherwise." :warning)) (let ((file-count 0) + (pop-up-tabs pop-up-tabs) first-file-buffer) (when command-line-args-left ;; We have command args; process them. @@ -2104,7 +2105,7 @@ A fancy display is used on graphic displays, normal otherwise." ;; This includes our standard options' long versions ;; and long versions of what's on command-switch-alist. (longopts - (append '("--funcall" "--load" "--insert" "--kill" + (append '("--funcall" "--load" "--insert" "--kill" "--tabs" "--directory" "--eval" "--execute" "--no-splash" "--find-file" "--visit" "--file" "--no-desktop") (mapcar (lambda (elt) (concat "-" (car elt))) @@ -2236,6 +2237,9 @@ A fancy display is used on graphic displays, normal otherwise." (setq command-line-args-left (nthcdr (nth 1 cl1-tem) command-line-args-left))) + ((equal argi "-tabs") + (setq pop-up-tabs t)) + ((member argi '("-find-file" "-file" "-visit")) (setq inhibit-startup-screen t) ;; An explicit option to specify visiting a file. @@ -2248,7 +2252,9 @@ A fancy display is used on graphic displays, normal otherwise." cl1-dir))) (if (= file-count 1) (setq first-file-buffer (find-file file)) - (find-file-other-window file))) + (if pop-up-tabs + (find-file-other-tab file) + (find-file-other-window file)))) (unless (zerop cl1-line) (goto-char (point-min)) (forward-line (1- cl1-line))) @@ -2281,6 +2287,8 @@ A fancy display is used on graphic displays, normal otherwise." cl1-dir))) (cond ((= file-count 1) (setq first-file-buffer (find-file file))) + (pop-up-tabs + (find-file-other-tab file)) (inhibit-startup-screen (find-file-other-window file)) (t (find-file file)))) @@ -2321,6 +2329,7 @@ A fancy display is used on graphic displays, normal otherwise." (and (> file-count 2) (not noninteractive) (not inhibit-startup-buffer-menu) + (not pop-up-tabs) (or (get-buffer-window first-file-buffer) (list-buffers))) @@ -2356,9 +2365,13 @@ A fancy display is used on graphic displays, normal otherwise." ;; (with-no-warnings ;; (setq menubar-bindings-done t)) - (if (> file-count 0) - (display-startup-screen t) - (display-startup-screen nil))))) + (cond (pop-up-tabs + (select-tab (make-tab nil nil 1)) + (display-startup-screen nil)) + ((> file-count 0) + (display-startup-screen t)) + (t + (display-startup-screen nil)))))) (defun command-line-normalize-file-name (file) "Collapse multiple slashes to one, to handle non-Emacs file names." diff --git a/src/emacs.c b/src/emacs.c index 400a6b0e594..6d74e927e60 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -298,6 +298,7 @@ FILE visit FILE using find-file\n\ --insert FILE insert contents of FILE into current buffer\n\ --kill exit without asking for confirmation\n\ --load, -l FILE load Emacs Lisp FILE using the load function\n\ +--tabs use tabs to visit files in a new tab\n\ --visit FILE visit FILE using find-file\n\ \n" @@ -1887,6 +1888,7 @@ const struct standard_args standard_args[] = { "-eval", "--eval", 0, 1 }, { "-execute", "--execute", 0, 1 }, { "-find-file", "--find-file", 0, 1 }, + { "-tabs", "--tabs", 0, 0 }, { "-visit", "--visit", 0, 1 }, { "-file", "--file", 0, 1 }, { "-insert", "--insert", 0, 1 }, -- 2.39.5