Skip to content

Instantly share code, notes, and snippets.

@mikedll
Last active February 24, 2019 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikedll/5b353c913225cd4303658ba7bf7aecb3 to your computer and use it in GitHub Desktop.
Save mikedll/5b353c913225cd4303658ba7bf7aecb3 to your computer and use it in GitHub Desktop.
Parse lines of a file.
(defun get-lines()
(let* ((mine-file (concat settings-dir "/common/emacs/mike/mine.txt"))
(cur-line nil)
(files-to-load (list))
(my-configs-buf (find-file-noselect mine-file)))
(with-current-buffer my-configs-buf
(goto-char (point-min))
(while (not (eq (point) (point-max)))
(setq cur-line (thing-at-point 'line t))
(cond ((string-match "^#" cur-line)
(setq cur-line nil))
((string-match "\n" cur-line)
(setq cur-line (replace-match "" t nil cur-line)))
(t (setq cur-line nil)))
(if (not (null cur-line))
(setq files-to-load (cons cur-line files-to-load)))
(forward-line)))
;; reverse, since we cons-ed the list when building it.
(reverse files-to-load)))
(dolist (file (get-lines))
(message file))
# Will be loaded in this order.
mikedll-emacs-defaults.el
osx.el
windows.el
linux.el
mikedll-emacs-extensions.el
mikedll-editing-settings.el
load-languages.el
load-tools.el
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment