Centaur-Emacs

Table of Contents

1. init.el

1.1. Add debug feature

(setq debug-on-error t)
              
ping 192.168.1.1
              

2. customer-post.org

2.1. Require file

2.1.1. Website

;;; init-site.el --- Exports org to site. -*- lexical-binding: t; -*-
                  ;;; Commentary:
                  ;;; Code:

                  (use-package htmlize
                  :ensure t
                  ;; :config
                  ;; (setq htmlize-output-type 'font)
                  )

                  (progn
                  "Settings of `org-export'."
                  (setq org-export-in-background t
                  ;; Hide html built-in style and script.
                  org-html-htmlize-output-type 'inline-css
                  org-html-head-include-default-style nil
                  org-html-head-include-scripts nil
                  ))

                  (eval-after-load 'ox-html
                  (setq user-full-name "YF Lin"))

                  ;;(use-package ox-publish
                  ;;  :config
                  (setq org-publish-project-alist
                  '(("orgfiles"
                  ;; ; Sources and destinations for files.
                  :base-directory "~/site/org/" ;; local dir
                  :publishing-directory "~/site/public/" ;; :publishing-directory "/ssh:jack@192.112.245.112:~/site/public/"
                  ;; :preparation-function
                  ;; :complete-function
                  :base-extension "org"
                  ;; :exclude "PrivatePage.org"     ;; regexp
                  ;; :include
                  :recursive t

                  ;; ; Publishing action
                  :publishing-function org-html-publish-to-html

                  ;; ; Generic properties
                  :headline-levels 6    ;; org-export-headline-levels
                  :language "en"        ;; org-export-default-language
                  :section-numbers nil  ;; org-export-with-section-numbers
                  :with-planning t      ;; org-export-with-planning
                  :with-priority t      ;; org-export-with-priority ;
                  ;;  :with-tags not-in-toc ;; org-export-with-tags
                  :with-toc t           ;; org-export-with-toc

                  :html-doctype "html5" ;; org-html-doctype
                  ;;  :html-metadata-timestamp-format "%Y-%m-%d" ;; org-html-metadata-timestamp-format
                  :html-head-include-default-style nil ;; org-html-head-include-default-style
                  :html-head-include-scripts nil ;; org-html-head-include-scripts
                  :html-head
                  "<link rel=\"shortcut icon\" href=\"themes/assets/xx.png\" type=\"image/x-icon\" />
                  <link rel=\"stylesheet\" href=\"themes/style.css\" type=\"text/css\"  />
                  <script type=\"module\" src=\"themes/main.js\" defer></script>" ;; org-html-head
                  :html-checkbox-type unicode  ;; org-html-checkbox-type
                  ;; :html-indent t               ;; org-html-indent
                  ;; :html-link-home "index.html"	;; org-html-link-home
                  ;; :html-link-up "uUP"          ;; org-html-link-up
                  :html-validation-link "<a href=\"http://www.thethingsengine.org/\">ThingsEngine</a>"	;; org-html-validation-link
                  )

                  ;; static assets
                  ("confs"
                  :base-directory "~/site/"
                  :base-extension "js"
                  :publishing-directory "~/site/public/"
                  :recursive nil
                  :publishing-function org-publish-attachment
                  )
                  ("images"
                  :base-directory "~/site/images/"
                  :base-extension any
                  :publishing-directory "~/site/public/images/"
                  :recursive t
                  :publishing-function org-publish-attachment
                  )
                  ("themes"
                  :base-directory "~/site/themes/"
                  :base-extension any
                  :publishing-directory "~/site/public/themes/"
                  :recursive t
                  :publishing-function org-publish-attachment
                  )

                  ("website" :components ("orgfiles" "confs" "images" "themes"))
                  ("statics" :components ("confs" "images" "themes"))
                  ));;)

                  (defun save-and-publish-website()
                  "Save all buffers and publish."
                  (interactive)
                  (when (yes-or-no-p "Really save and publish current project?")
                  (save-some-buffers t)
                  (org-publish-project "website" t)
                  (message "Site published done.")))

                  (defun save-and-publish-statics ()
                  "Just copy statics like js, css, and image file .etc."
                  (interactive)
                  (org-publish-project "statics" t)
                  (message "Copy statics done."))

                  (defun save-and-publish-file ()
                  "Save current buffer and publish."
                  (interactive)
                  (save-buffer t)
                  (org-publish-current-file t))

                  (defun delete-org-and-html ()
                  "Delete current org and the relative html when it exists."
                  (interactive)
                  (when (yes-or-no-p "Really delete current org and the relative html?")

                  (let ((fileurl (concat "~/site/public/" (file-name-base (buffer-name)) ".html")))
                  (if (file-exists-p fileurl)
                  (delete-file fileurl))
                  (delete-file (buffer-file-name))
                  (kill-this-buffer)
                  (message "Delete org and the relative html done."))))

                  (defun just-delete-relative-html ()
                  "Just delete the relative html when it exists."
                  (interactive)
                  (when (yes-or-no-p "Really delete the relative html?")

                  (let ((fileurl (concat "~/site/public/" (file-name-base (buffer-name)) ".html")))
                  (if (file-exists-p fileurl)
                  (progn
                  (delete-file fileurl)
                  (message "Delete the relative html done.")
                  )
                  (message "None relative html.")))))

                  (define-minor-mode auto-save-and-publish-file-mode
                  "Toggle auto save and publish current file."
                  :global nil
                  :lighter ""
                  (if auto-save-and-publish-file-mode
                  ;; When the mode is enabled
                  (progn
                  (add-hook 'after-save-hook #'save-and-publish-file :append :local))
                  ;; When the mode is disabled
                  (remove-hook 'after-save-hook #'save-and-publish-file :local)))

                  ;;(use-package auto-save-and-publish-file-mode
                  ;;:hook (org-mode))

                  (add-hook 'org-mode-hook #'auto-save-and-publish-file-mode)

                  (use-package simple-httpd
                  :ensure t
                  :config
                  (setq httpd-root "~/site/public"))

                  (defun preview-current-buffer-in-browser ()
                  "Open current buffer as html."
                  (interactive)
                  (let ((fileurl (concat "http://127.0.0.1:8080/" (file-name-base (buffer-name)) ".html")))
                  (save-and-publish-file)
                  (unless (httpd-running-p) (httpd-start))
                  (browse-url fileurl)))

                  (provide 'init-site)
                  ;;; init-site.el ends here
                

2.1.2. Add Require

(require 'init-site)
                  (require 'sound-wav)
                

2.2. Addtional Package

2.2.1. Centaur Tab

(use-package centaur-tabs
                  :ensure t
                  :config
                  (setq centaur-tabs-style "bar"
                  centaur-tabs-height 22
                  centaur-tabs-set-icons t
                  centaur-tabs-plain-icons t
                  centaur-tabs-gray-out-icons t
                  centaur-tabs-set-close-button t
                  centaur-tabs-set-modified-marker t
                  centaur-tabs-show-navigation-buttons t
                  centaur-tabs-set-bar 'left
                  centaur-tabs-cycle-scope 'tabs
                  x-underline-at-descent-line nil)
                  (centaur-tabs-headline-match)
                  ;; (setq centaur-tabs-gray-out-icons 'buffer)
                  ;; (centaur-tabs-enable-buffer-reordering)
                  ;; (setq centaur-tabs-adjust-buffer-order t)
                  (centaur-tabs-mode 1)
                  (setq uniquify-separator "/")
                  (setq uniquify-buffer-name-style 'forward)
                  (defun centaur-tabs-buffer-groups ()
                  "`centaur-tabs-buffer-groups' control buffers' group rules.
                  Group centaur-tabs with mode if buffer is derived from `eshell-mode' `emacs-lisp-mode' `dired-mode' `org-mode' `magit-mode'.
                  All buffer name start with * will group to \"Emacs\".
                  Other buffer group by `centaur-tabs-get-group-name' with project name."
                  (list
                  (cond
                  ((ignore-errors
                  (and (string= "*xwidget" (substring (buffer-name) 0 8))
                  (not (string= "*xwidget-log*" (buffer-name)))))
                  "Xwidget")
                  ((or (string-equal "*" (substring (buffer-name) 0 1))
                  (memq major-mode '(magit-process-mode
                  magit-status-mode
                  magit-diff-mode
                  magit-log-mode
                  magit-file-mode
                  magit-blob-mode
                  magit-blame-mode
                  )))
                  "Emacs")
                  ((derived-mode-p 'prog-mode)
                  "Editing")
                  ((derived-mode-p 'dired-mode)
                  "Dired")
                  ((memq major-mode '(helpful-mode
                  help-mode))
                  "Help")
                  ((memq major-mode '(org-mode
                  org-agenda-clockreport-mode
                  org-src-mode
                  org-agenda-mode
                  org-beamer-mode
                  org-indent-mode
                  org-bullets-mode
                  org-cdlatex-mode
                  org-agenda-log-mode
                  diary-mode))
                  "OrgMode")
                  (t
                  (centaur-tabs-get-group-name (current-buffer))))))
                  :hook
                  (dashboard-mode . centaur-tabs-local-mode)
                  (term-mode . centaur-tabs-local-mode)
                  (calendar-mode . centaur-tabs-local-mode)
                  (org-agenda-mode . centaur-tabs-local-mode)
                  (helpful-mode . centaur-tabs-local-mode)
                  :bind
                  ("C-c b" . centaur-tabs-backward)
                  ("C-c n" . centaur-tabs-forward)
                  ("C-c m" . centaur-tabs-forward-group)
                  ("C-c v" . centaur-tabs-backward-group))
                

2.2.2. insert screenshots

Mojave has a new screenshot capability you get with SHIFT-COMMAND-5. After typing SHIFT-COMMAND-5, select OPTIONS, then select "save to desktop" and then the Dropbox saving funtionality. Clipboard

(use-package org-download
                  :after org
                  :defer nil
                  :custom
                  (org-download-method 'directory)
                  (org-download-image-dir "images")
                  (org-download-heading-lvl nil)
                  (org-download-timestamp "%Y%m%d-%H%M%S_")
                  (org-image-actual-width 300)
                  (org-download-screenshot-method "/usr/local/bin/pngpaste %s")
                  :bind
                  ("C-s-y" . org-download-screenshot)
                  :config
                  (require 'org-download))
                

2.3. Key Binding

2.3.1. Org-capture

(global-set-key (kbd "s-1")
                  'org-capture)
                
  1. Org-caputure template
    (setq org-capture-templates
                          '(("a" "Appointment" entry (file+headline  "~/org/GTD/appointment.org" "Appointments")
                          "* TODO %?\n:PROPERTIES:\n\n:END:\nDEADLINE: %^T \n %i\n")
                          ("n" "Note" entry (file+headline "~/org/GTD/notes.org" "Notes")
                          "* Note %?\n%T")
                          ("l" "Link" entry (file+headline "~/org/GTD/links.org" "Links")
                          "* %? %^L %^g \n%T" :prepend t)
                          ("b" "Blog idea" entry (file+headline "~/org/GTD/i.org" "Blog Topics:")
                          "* %?\n%T" :prepend t)
                          ("t" "To Do Item" entry (file+headline "~/org/GTD/task.org" "To Do Items")
                          "* %?\n%T" :prepend t)
                          ("j" "Journal" entry (file+datetree "~/org/GTD/journal.org")
                          "* %?\nEntered on %U\n  %i\n  %a")
                          ("s" "Screencast" entry (file "~/org/GTD/screencastnotes.org")
                          "* %?\n%i\n")))
                        

2.4. TE-fun

2.4.1. Number to Binary

(defun TE-number-to-bin-string (number)
                  (require 'calculator)
                  (let ((calculator-output-radix 'bin)
                  (calculator-radix-grouping-mode nil))
                  (calculator-number-to-string number)))
                

2.5. Latex

  (load "auctex.el" nil t t)
                ;;(load "preview-latex.el" nil t t)
                (setq TeX-auto-save t)
                (setq TeX-parse-self t)
                (setq-default TeX-master nil)



                ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;RefTex;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
                (require 'reftex)
                (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
                (setq reftex-plug-into-AUCTeX t)
                (setq reftex-enable-partial-scans t)
                (setq reftex-save-parse-info t)
                (setq reftex-use-multiple-selection-buffers t)
                (setq reftex-toc-split-windows-horizontally t) ;;*toc*buffer on left。
                (setq reftex-toc-split-windows-fraction 0.2)  ;;*toc*buffer ratio。
                (autoload 'reftex-mode "reftex" "RefTeX Minor Mode" t)
                (autoload 'turn-on-reftex "reftex" "RefTeX Minor Mode" nil)
                (autoload 'reftex-citation "reftex-cite" "Make citation" nil)  
                (autoload 'reftex-index-phrase-mode "reftex-index" "Phrase mode" t)

                ;;;;;;;;;;;;;;;;;;;;;;;;;;CDLaTeX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                (add-hook 'LaTeX-mode-hook 'turn-on-cdlatex)
                (autoload 'cdlatex-mode "cdlatex" "CDLaTeX Mode" t)
                (autoload 'turn-on-cdlatex "cdlatex" "CDLaTeX Mode" nil)


                ;;;;;;;;;;;;;;;;;;;;;;;;;;;LaTex-mode settings;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                (add-hook 'LaTeX-mode-hook (lambda ()
                ;(require 'init-auto-complete-settings)
                ;(require 'init-yasnippet-settings)
                (TeX-fold-mode 1)
                (auto-fill-mode 1)

                ;;;;;;;;;;;;;;;; flyspell settings
                (flyspell-mode 1)
                (setq flyspell-sort-corrections nil)
                (setq flyspell-doublon-as-error-flag nil)


                (turn-on-auto-fill)              ;;LaTeX mode,turn off auto fold
                (linum-mode 1)
                ;;(auto-complete-mode 1)
                (latex-math-mode 1)
                (outline-minor-mode 1)            
                (imenu-add-menubar-index)

                (setq TeX-show-compilation nil)   ;;NOT display compilation windows
                (setq TeX-global-PDF-mode t       ;;PDF mode enable, not plain
                TeX-engine 'default)  ;;use xelatex default
                (setq TeX-clean-confirm nil)
                (setq TeX-save-query nil)

                (setq font-latex-fontify-script t)
                (define-key LaTeX-mode-map (kbd "TAB") 'TeX-complete-symbol)
                (setq TeX-electric-escape t)      ;; press \ then, jump to mini-buffer to input commands
                ;(setq TeX-view-program-list '(("Evince" "evince %o"))) ;;
                ; (setq TeX-view-program-selection '((output-pdf "Evince")))
                ;(add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
                ;(setq TeX-command-default "XeLaTeX")
                (setq TeX-fold-env-spec-list (quote (("[comment]" ("comment")) ("[figure]" ("figure")) ("[table]" ("table"))("[itemize]"("itemize"))("[enumerate]"("enumerate"))("[description]"("description"))("[overpic]"("overpic"))("[tabularx]"("tabularx"))("[code]"("code"))("[shell]"("shell")))))


                (define-key LaTeX-mode-map (kbd "C-c C-p") 'reftex-parse-all)

                ;;;;;;deeper directory;;;;;;;;;;;;;
                ;(setq reftex-section-levels
                ;     '(("part" . 0) ("chapter" . 1) ("section" . 2) ("subsection" . 3)
                ;       ("frametitle" . 4) ("subsubsection" . 4) ("paragraph" . 5)
                ;       ("subparagraph" . 6) ("addchap" . -1) ("addsec" . -2)))


                (setq LaTeX-section-hook
                '(LaTeX-section-heading
                LaTeX-section-title
                LaTeX-section-toc
                LaTeX-section-section
                LaTeX-section-label))
                ));;

              

Date: 2020-10-05 Mon 00:00

Author: YF Lin

Created: 2023-02-24 Fri 10:00

ThingsEngine