<commit_before>;; Time-stamp: <2015-04-09 23:53:46 kmodi>

;; Set up the looks of emacs

;; Highlight closing parentheses; show the name of the body being closed with
;; the closing parentheses in the minibuffer.
(show-paren-mode +1)

(defvar default-font-size-pt 13
  "Default font size in points.")

(defvar dark-theme t
  "Variable to store the nature of theme whether it is light or dark.
This variable is to be updated when changing themes.")

(setq frame-resize-pixelwise t) ; allow frame size to inc/dec by a pixel

;; MENU/TOOL/SCROLL BARS
;; Turn off mouse interface early in startup to avoid momentary display
(if (fboundp 'menu-bar-mode)   (menu-bar-mode -1)) ; do not show the menu bar with File|Edit|Options|...
(if (fboundp 'tool-bar-mode)   (tool-bar-mode -1)) ; do not show the tool bar with icons on the top
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) ; disable the scroll bars

(setq inhibit-startup-message t ; No splash screen at startup
      scroll-step 1 ; scroll 1 line at a time
      tooltip-mode nil ; disable tooltip appearance on mouse hover
      )

;;                     THEME-NAME      DARK   FCI-RULE-COLOR
(defconst my/themes '((smyx            'dark  "gray40")
                      (zenburn         'dark  "gray40")
                      (darktooth       'dark  "gray40")
                      (ample           'dark  "gray40")
                      (ample-flat      'dark  "gray40")
                      (planet          'dark  "gray40")
                      (ample-light     'light "gray")
                      (leuven          'light "gray")
                      (twilight-bright 'light "gray")
                      (default         'light "gray")) ; default emacs theme
  "Alist of themes I tend to switch to frequently.")

(defun my/disable-enabled-themes ()
  "Disable all enable themes except the one used by `smart-mode-line'.

This function is not meant for interactive use. A clean way to disable all
themes will be to run `M-x load-theme/default' (this function is generated
by the `modi/gen-all-theme-fns' macro. That will ensure that all
themes are disabled and also fix the faces for linum, fringe, etc."
  (dolist (theme custom-enabled-themes)
    (unless (string-match "smart-mode-line-" (format "%s" theme))
      (disable-theme theme))))

;; How can I create multiple defuns by looping through a list?
;; http://emacs.stackexchange.com/a/10122/115
(defun modi/gen-theme-fn (theme-name dark fci-rule-color)
  "Function to generate a function to disable all themes and enable the chosen
theme, while also customizing few faces outside the theme.

The theme loading functions are named “load-theme/THEME-NAME”.
Example: For `smyx' theme, the generated function will be `load-theme/smyx'.

The DARK variable should be set to `'dark' if the theme is dark and `'light'
if otherwise.

The FCI-RULE-COLOR is the color string to set the color for fci rules.

Running `M-x load-theme/default' will disable all custom themes except
the smart-mode-line theme."
  (let ((theme-fn-name (intern (format "load-theme/%s" theme-name))))
    `(defun ,theme-fn-name ()
       (interactive)
       ;; `dark-theme' is set to `t' if `dark' value is `'dark'
       (setq dark-theme (equal ,dark 'dark))
       (my/disable-enabled-themes)
       (when (not (equal ',theme-name 'default))
         (load-theme ',theme-name t))
       (when (featurep 'defuns)
         (modi/blend-fringe))
       (when (featurep 'setup-linum)
         (modi/blend-linum))
       (when (featurep 'smart-mode-line)
         (sml/apply-theme ,dark nil :silent)) ; apply sml theme silently
       (when (featurep 'setup-fci)
         ;; Below commented code does not work
         ;; (setq fci-rule-color (face-foreground 'font-lock-comment-face))
         (setq fci-rule-color ,fci-rule-color)
         (modi/fci-redraw-frame-all-buffers)))))

(defmacro modi/gen-all-theme-fns ()
  `(progn ,@(mapcar
             (lambda (x) (modi/gen-theme-fn (nth 0 x) (nth 1 x) (nth 2 x)))
             my/themes)))

(modi/gen-all-theme-fns)
;; (pp (macroexpand '(modi/gen-all-theme-fns))) ; for debug

(defconst default-dark-theme-fn  'load-theme/smyx
  "Function to set the default dark theme.")
(defconst default-light-theme-fn 'load-theme/leuven
  "Function to set the default light theme.")
(defconst default-theme-fn default-dark-theme-fn
  "Function to set the default theme.")

(defun toggle-theme ()
  "Toggles theme between the default light and default dark themes."
  (interactive)
  (if dark-theme
      (funcall default-light-theme-fn)
    (funcall default-dark-theme-fn)))

;; Load the theme ONLY after the frame has finished loading (needed especially
;; when running emacs in daemon mode)
;; https://github.com/Malabarba/smart-mode-line/issues/84#issuecomment-46429893
;; `after-make-frame-functions' hook is not run in no-window mode
(add-hook 'after-make-frame-functions (lambda (&rest frame)
                                        (funcall default-theme-fn)))

;; Make the italics show as actual italics. For some unknown reason, the below
;; is needed to render the italics in org-mode. The issue could be related to
;; the fonts in use. But having this doesn't hurt regardless.
(set-face-attribute 'italic nil :inherit nil :slant 'italic)

(defun modi/update-frame-title ()
  (interactive)
  ;; Frame title bar format
  ;; If buffer-file-name exists, show it;
  ;; else if you are in dired mode, show the directory name
  ;; else show only the buffer name (*scratch*, *Messages*, etc)
  (setq frame-title-format (list '(buffer-file-name "%f"
                                   (dired-directory dired-directory "%b")))))
(add-hook 'after-init-hook #'modi/update-frame-title)

;; Enable font-lock or syntax highlighting globally
(setq global-font-lock-mode t)
;; Use the maximum decoration level available for color highlighting
(setq font-lock-maximum-decoration t)

;; FONTS
;; (set-face-attribute 'default nil :font "Source Code Pro for Powerline" )
;; (set-frame-font "Input Mono" nil t)

;; Manually choose a fallback font for Unicode
;; http://endlessparentheses.com/manually-choose-a-fallback-font-for-unicode.html
(set-fontset-font "fontset-default" nil
                  (font-spec :size 20 :name "Symbola"))
<commit_msg>Confused: Reverting to using window-setup-hook<commit_after>;; Time-stamp: <2015-04-13 16:02:55 kmodi>

;; Set up the looks of emacs

;; Highlight closing parentheses; show the name of the body being closed with
;; the closing parentheses in the minibuffer.
(show-paren-mode +1)

(defvar default-font-size-pt 13
  "Default font size in points.")

(defvar dark-theme t
  "Variable to store the nature of theme whether it is light or dark.
This variable is to be updated when changing themes.")

(setq frame-resize-pixelwise t) ; allow frame size to inc/dec by a pixel

;; MENU/TOOL/SCROLL BARS
;; Turn off mouse interface early in startup to avoid momentary display
(if (fboundp 'menu-bar-mode)   (menu-bar-mode -1)) ; do not show the menu bar with File|Edit|Options|...
(if (fboundp 'tool-bar-mode)   (tool-bar-mode -1)) ; do not show the tool bar with icons on the top
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) ; disable the scroll bars

(setq inhibit-startup-message t ; No splash screen at startup
      scroll-step 1 ; scroll 1 line at a time
      tooltip-mode nil ; disable tooltip appearance on mouse hover
      )

;;                     THEME-NAME      DARK   FCI-RULE-COLOR
(defconst my/themes '((smyx            'dark  "gray40")
                      (zenburn         'dark  "gray40")
                      (darktooth       'dark  "gray40")
                      (ample           'dark  "gray40")
                      (ample-flat      'dark  "gray40")
                      (planet          'dark  "gray40")
                      (ample-light     'light "gray")
                      (leuven          'light "gray")
                      (twilight-bright 'light "gray")
                      (default         'light "gray")) ; default emacs theme
  "Alist of themes I tend to switch to frequently.")

(defun my/disable-enabled-themes ()
  "Disable all enable themes except the one used by `smart-mode-line'.

This function is not meant for interactive use. A clean way to disable all
themes will be to run `M-x load-theme/default' (this function is generated
by the `modi/gen-all-theme-fns' macro. That will ensure that all
themes are disabled and also fix the faces for linum, fringe, etc."
  (dolist (theme custom-enabled-themes)
    (unless (string-match "smart-mode-line-" (format "%s" theme))
      (disable-theme theme))))

;; How can I create multiple defuns by looping through a list?
;; http://emacs.stackexchange.com/a/10122/115
(defun modi/gen-theme-fn (theme-name dark fci-rule-color)
  "Function to generate a function to disable all themes and enable the chosen
theme, while also customizing few faces outside the theme.

The theme loading functions are named “load-theme/THEME-NAME”.
Example: For `smyx' theme, the generated function will be `load-theme/smyx'.

The DARK variable should be set to `'dark' if the theme is dark and `'light'
if otherwise.

The FCI-RULE-COLOR is the color string to set the color for fci rules.

Running `M-x load-theme/default' will disable all custom themes except
the smart-mode-line theme."
  (let ((theme-fn-name (intern (format "load-theme/%s" theme-name))))
    `(defun ,theme-fn-name ()
       (interactive)
       ;; `dark-theme' is set to `t' if `dark' value is `'dark'
       (setq dark-theme (equal ,dark 'dark))
       (my/disable-enabled-themes)
       (when (not (equal ',theme-name 'default))
         (load-theme ',theme-name t))
       (when (featurep 'defuns)
         (modi/blend-fringe))
       (when (featurep 'setup-linum)
         (modi/blend-linum))
       (when (featurep 'smart-mode-line)
         (sml/apply-theme ,dark nil :silent)) ; apply sml theme silently
       (when (featurep 'setup-fci)
         ;; Below commented code does not work
         ;; (setq fci-rule-color (face-foreground 'font-lock-comment-face))
         (setq fci-rule-color ,fci-rule-color)
         (modi/fci-redraw-frame-all-buffers)))))

(defmacro modi/gen-all-theme-fns ()
  `(progn ,@(mapcar
             (lambda (x) (modi/gen-theme-fn (nth 0 x) (nth 1 x) (nth 2 x)))
             my/themes)))

(modi/gen-all-theme-fns)
;; (pp (macroexpand '(modi/gen-all-theme-fns))) ; for debug

(defconst default-dark-theme-fn  'load-theme/smyx
  "Function to set the default dark theme.")
(defconst default-light-theme-fn 'load-theme/leuven
  "Function to set the default light theme.")
(defconst default-theme-fn default-dark-theme-fn
  "Function to set the default theme.")

(defun toggle-theme ()
  "Toggles theme between the default light and default dark themes."
  (interactive)
  (if dark-theme
      (funcall default-light-theme-fn)
    (funcall default-dark-theme-fn)))

;; Load the theme ONLY after the frame has finished loading (needed especially
;; when running emacs in daemon mode)
;; https://github.com/Malabarba/smart-mode-line/issues/84#issuecomment-46429893
;; ;; `after-make-frame-functions' hook is not run in no-window mode
;; (add-hook 'after-make-frame-functions (lambda (&rest frame)
;;                                         (funcall default-theme-fn)))
(add-hook 'window-setup-hook (λ (funcall default-theme-fn)))

;; Make the italics show as actual italics. For some unknown reason, the below
;; is needed to render the italics in org-mode. The issue could be related to
;; the fonts in use. But having this doesn't hurt regardless.
(set-face-attribute 'italic nil :inherit nil :slant 'italic)

(defun modi/update-frame-title ()
  (interactive)
  ;; Frame title bar format
  ;; If buffer-file-name exists, show it;
  ;; else if you are in dired mode, show the directory name
  ;; else show only the buffer name (*scratch*, *Messages*, etc)
  (setq frame-title-format (list '(buffer-file-name "%f"
                                   (dired-directory dired-directory "%b")))))
(add-hook 'after-init-hook #'modi/update-frame-title)

;; Enable font-lock or syntax highlighting globally
(setq global-font-lock-mode t)
;; Use the maximum decoration level available for color highlighting
(setq font-lock-maximum-decoration t)

;; FONTS
;; (set-face-attribute 'default nil :font "Source Code Pro for Powerline" )
;; (set-frame-font "Input Mono" nil t)

;; Manually choose a fallback font for Unicode
;; http://endlessparentheses.com/manually-choose-a-fallback-font-for-unicode.html
(set-fontset-font "fontset-default" nil
                  (font-spec :size 20 :name "Symbola"))

{'fraction_non_alphanumeric': 0.11637487126673532, 'fraction_numerical': 0.009031133644933851, 'mean_word_length': 2.8115942028985508, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '746110', 'n_tokens_mistral': 4033, 'n_tokens_neox': 3845, 'n_words': 1363}