48 lines
1.9 KiB
EmacsLisp
48 lines
1.9 KiB
EmacsLisp
;; (C) Copyright Collin J. Doering 2020
|
|
;;
|
|
;; This program is free software: you can redistribute it and/or modify
|
|
;; it under the terms of the GNU General Public License as published by
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
;; (at your option) any later version.
|
|
;;
|
|
;; This program is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
;; GNU General Public License for more details.
|
|
;;
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
;; Even though this is not used, it needs to be here so that package.el
|
|
;; doesn't re-add it uncommented
|
|
;; (package-initialize)
|
|
|
|
;;; Code:
|
|
|
|
(require 'org)
|
|
(require 'ob-tangle)
|
|
|
|
(let* ((filename (concat (file-name-directory load-file-name) "config"))
|
|
(config (concat filename ".org"))
|
|
(el (concat filename ".el"))
|
|
; Temporarily (for this block, specifically org-babel-tangle-file below) turn off
|
|
; babel evaluation confirmation, as its triggered for tangle to files that are marked
|
|
; executable (new in org 9.6)
|
|
(org-confirm-babel-evaluate nil))
|
|
(when (file-exists-p config)
|
|
(when (or (not (file-exists-p el))
|
|
(time-less-p
|
|
(file-attribute-modification-time (file-attributes el))
|
|
(file-attribute-modification-time (file-attributes config))))
|
|
(org-babel-tangle-file config el)
|
|
;; Make sure that tangled file modification time is
|
|
;; updated even when `org-babel-tangle-file' does not make changes.
|
|
;; This avoids re-tangling changed FILE where the changes did
|
|
;; not affect the tangled code.
|
|
(when (file-exists-p el)
|
|
(set-file-times el))
|
|
|
|
(byte-compile-file el)
|
|
(load-file (byte-compile-dest-file el))
|
|
(message "Compiled and loaded %s" el))))
|