comparison lisp/startup.el @ 14386:4e5b28d28a5f

(command-line-normalize-file-name): New function. (command-line-1): Call it to handle foo//bar in non-Emacs fashion.
author Richard M. Stallman <rms@gnu.org>
date Sat, 27 Jan 1996 00:14:59 +0000
parents b747e8369639
children fe6846ee5999
comparison
equal deleted inserted replaced
14385:aa3232e9077f 14386:4e5b28d28a5f
839 (string-equal argi "-directory")) 839 (string-equal argi "-directory"))
840 (if argval 840 (if argval
841 (setq tem argval) 841 (setq tem argval)
842 (setq tem (car command-line-args-left) 842 (setq tem (car command-line-args-left)
843 command-line-args-left (cdr command-line-args-left))) 843 command-line-args-left (cdr command-line-args-left)))
844 (setq tem (command-line-normalize-file-name tem))
844 (setq extra-load-path 845 (setq extra-load-path
845 (cons (expand-file-name tem) extra-load-path)) 846 (cons (expand-file-name tem) extra-load-path))
846 (setq load-path (append (nreverse extra-load-path) 847 (setq load-path (append (nreverse extra-load-path)
847 initial-load-path))) 848 initial-load-path)))
848 ((or (string-equal argi "-l") 849 ((or (string-equal argi "-l")
849 (string-equal argi "-load")) 850 (string-equal argi "-load"))
850 (if argval 851 (if argval
851 (setq tem argval) 852 (setq tem argval)
852 (setq tem (car command-line-args-left) 853 (setq tem (car command-line-args-left)
853 command-line-args-left (cdr command-line-args-left))) 854 command-line-args-left (cdr command-line-args-left)))
854 (let ((file tem)) 855 (let ((file (command-line-normalize-file-name tem)))
855 ;; Take file from default dir if it exists there; 856 ;; Take file from default dir if it exists there;
856 ;; otherwise let `load' search for it. 857 ;; otherwise let `load' search for it.
857 (if (file-exists-p (expand-file-name file)) 858 (if (file-exists-p (expand-file-name file))
858 (setq file (expand-file-name file))) 859 (setq file (expand-file-name file)))
859 (load file nil t))) 860 (load file nil t)))
862 (setq tem argval) 863 (setq tem argval)
863 (setq tem (car command-line-args-left) 864 (setq tem (car command-line-args-left)
864 command-line-args-left (cdr command-line-args-left))) 865 command-line-args-left (cdr command-line-args-left)))
865 (or (stringp tem) 866 (or (stringp tem)
866 (error "File name omitted from `-insert' option")) 867 (error "File name omitted from `-insert' option"))
867 (insert-file-contents tem)) 868 (insert-file-contents (command-line-normalize-file-name tem)))
868 ((string-equal argi "-kill") 869 ((string-equal argi "-kill")
869 (kill-emacs t)) 870 (kill-emacs t))
870 ((string-match "^\\+[0-9]+\\'" argi) 871 ((string-match "^\\+[0-9]+\\'" argi)
871 (setq line (string-to-int argi))) 872 (setq line (string-to-int argi)))
872 ((setq tem (assoc argi command-line-x-option-alist)) 873 ((setq tem (assoc argi command-line-x-option-alist))
885 ;; Ok, presume that the argument is a file name 886 ;; Ok, presume that the argument is a file name
886 (progn 887 (progn
887 (if (string-match "\\`-" argi) 888 (if (string-match "\\`-" argi)
888 (error "Unknown option `%s'" argi)) 889 (error "Unknown option `%s'" argi))
889 (setq file-count (1+ file-count)) 890 (setq file-count (1+ file-count))
891 (setq argi (command-line-normalize-file-name argi))
890 (cond ((= file-count 1) 892 (cond ((= file-count 1)
891 (setq first-file-buffer 893 (setq first-file-buffer
892 (find-file (expand-file-name argi dir)))) 894 (find-file (expand-file-name argi dir))))
893 (t 895 (t
894 (find-file-other-window (expand-file-name argi dir)))) 896 (find-file-other-window (expand-file-name argi dir))))
900 (if (> file-count 2) 902 (if (> file-count 2)
901 (or (get-buffer-window first-file-buffer) 903 (or (get-buffer-window first-file-buffer)
902 (progn (other-window 1) 904 (progn (other-window 1)
903 (buffer-menu))))))) 905 (buffer-menu)))))))
904 906
907 (defun command-line-normalize-file-name (file)
908 "Collapse multiple slashes to one, to handle non-Emacs file names."
909 (while (string-match "//+" file)
910 (setq file (replace-match "/" t t file)))
911 file)
912
905 ;;; startup.el ends here 913 ;;; startup.el ends here