chiark / gitweb /
el/dot-emacs.el: Factor out the command-line option scanning.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 13 Sep 2019 16:05:13 +0000 (17:05 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 13 Sep 2019 16:05:13 +0000 (17:05 +0100)
el/dot-emacs.el

index d2c9275cee2de514f33921bcfa169c584d550ea9..70d3b7a426056e59e16207df33709139e092e240 100644 (file)
 ;;;--------------------------------------------------------------------------
 ;;; Check command-line.
 
+(defun mdw-check-command-line-switch (switch)
+  (let ((probe nil) (next command-line-args) (found nil))
+    (while next
+      (cond ((string= (car next) switch)
+            (setq found t)
+            (if probe (rplacd probe (cdr next))
+              (setq command-line-args (cdr next))))
+           (t
+            (setq probe next)))
+      (setq next (cdr next)))
+    found))
+
 (defvar mdw-fast-startup nil
   "Whether .emacs should optimize for rapid startup.
 This may be at the expense of cool features.")
-(let ((probe nil) (next command-line-args))
-  (while next
-    (cond ((string= (car next) "--mdw-fast-startup")
-          (setq mdw-fast-startup t)
-          (if probe
-              (rplacd probe (cdr next))
-            (setq command-line-args (cdr next))))
-         (t
-          (setq probe next)))
-    (setq next (cdr next))))
+(setq mdw-fast-startup
+      (mdw-check-command-line-switch "--mdw-fast-startup"))
 
 ;;;--------------------------------------------------------------------------
 ;;; Some general utilities.