Browse Source

Make call-after-init a macro

master
10sr 5 years ago
parent
commit
aae06d9ea2
Signed by: 10sr GPG Key ID: 7BEC428194130EB2
1 changed files with 29 additions and 28 deletions
  1. +29
    -28
      emacs.el

+ 29
- 28
emacs.el View File

@@ -20,14 +20,17 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Some macros for internals ;; Some macros for internals


(defun call-after-init (func)
"If `after-init-hook' has been run, call FUNC immediately.
(defmacro call-after-init (&rest body)
"If `after-init-hook' has been run, run BODY immediately.
Otherwize hook it." Otherwize hook it."
(if after-init-time
;; Currently after-init-hook is run just after setting after-init-hook
(funcall func)
(add-hook 'after-init-hook
func)))
(declare (indent 0) (debug t))
`(if after-init-time
;; Currently after-init-hook is run just after setting after-init-hook
(progn
,@body)
(add-hook 'after-init-hook
(lambda ()
,@body))))


(defmacro safe-require-or-eval (feature) (defmacro safe-require-or-eval (feature)
"Require FEATURE if available. "Require FEATURE if available.
@@ -218,13 +221,12 @@ found, otherwise returns nil."
(set-scroll-bar-mode nil)) (set-scroll-bar-mode nil))


(call-after-init (call-after-init
(lambda ()
(message "%s %s" invocation-name emacs-version)
(message "Invocation directory: %s" default-directory)
(message "%s was taken to initialize emacs." (emacs-init-time))
(view-echo-area-messages)
;; (view-emacs-news)
))
(message "%s %s" invocation-name emacs-version)
(message "Invocation directory: %s" default-directory)
(message "%s was taken to initialize emacs." (emacs-init-time))
(view-echo-area-messages)
;; (view-emacs-news)
)


(with-current-buffer "*Messages*" (with-current-buffer "*Messages*"
(emacs-lock-mode 'kill)) (emacs-lock-mode 'kill))
@@ -248,10 +250,10 @@ found, otherwise returns nil."
;; (comint-show-maximum-output) ;; (comint-show-maximum-output)


;; kill scratch ;; kill scratch
(call-after-init (lambda ()
(let ((buf (get-buffer "*scratch*")))
(when buf
(kill-buffer buf)))))
(call-after-init
(let ((buf (get-buffer "*scratch*")))
(when buf
(kill-buffer buf))))


;; modifier keys ;; modifier keys
;; (setq mac-option-modifier 'control) ;; (setq mac-option-modifier 'control)
@@ -475,14 +477,13 @@ found, otherwise returns nil."
(when (safe-require-or-eval 'diminish) (when (safe-require-or-eval 'diminish)
;; FIXME: Eval after enabling mode ;; FIXME: Eval after enabling mode
(call-after-init (call-after-init
(lambda ()
(diminish 'recently-mode)
(diminish 'editorconfig-mode)
(diminish 'auto-highlight-symbol-mode)
(diminish 'global-whitespace-mode)
(diminish 'which-key-mode)
(diminish 'page-break-lines-mode)
(diminish 'highlight-indentation-mode))))
(diminish 'recently-mode)
(diminish 'editorconfig-mode)
(diminish 'auto-highlight-symbol-mode)
(diminish 'global-whitespace-mode)
(diminish 'which-key-mode)
(diminish 'page-break-lines-mode)
(diminish 'highlight-indentation-mode)))


;; http://www.geocities.jp/simizu_daisuke/bunkei-meadow.html#frame-title ;; http://www.geocities.jp/simizu_daisuke/bunkei-meadow.html#frame-title


@@ -1048,7 +1049,7 @@ found, otherwise returns nil."


;; https://github.com/lunaryorn/flycheck ;; https://github.com/lunaryorn/flycheck
(when (safe-require-or-eval 'flycheck) (when (safe-require-or-eval 'flycheck)
(call-after-init 'global-flycheck-mode))
(call-after-init (global-flycheck-mode)))


(when (autoload-eval-lazily 'ilookup) (when (autoload-eval-lazily 'ilookup)
(define-key ctl-x-map "d" 'ilookup-open-word)) (define-key ctl-x-map "d" 'ilookup-open-word))
@@ -1127,7 +1128,7 @@ found, otherwise returns nil."
;; (add-to-list 'load-path ;; (add-to-list 'load-path
;; (expand-file-name (concat user-emacs-directory "/cedet"))) ;; (expand-file-name (concat user-emacs-directory "/cedet")))
;; (safe-require-or-eval 'cedet-devel-load) ;; (safe-require-or-eval 'cedet-devel-load)
;; (call-after-init 'activate-malabar-mode))
;; (call-after-init (activate-malabar-mode)))


(with-eval-after-load 'make-mode (with-eval-after-load 'make-mode
(defvar makefile-mode-map (make-sparse-keymap)) (defvar makefile-mode-map (make-sparse-keymap))


Loading…
Cancel
Save