Sandy's .emacs.d

Table of Contents

emacs.png

1 Lorem Ipsum

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

2 MELPA

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

3 Coding styles

3.1 C

(setq-default c-basic-offset 8
              c-default-style "k&r"
              tab-width 8
              indent-tabs-mode t)

3.2 Python

(setq-default python-basic-offset 8
              tab-width 8
              indent-tabs-mode nil)

3.3 HTML

(add-hook 'html-mode-hook
          (lambda ()
            ;; Default indentation is usually 2 spaces, changing to 4.
            (set (make-local-variable 'sgml-basic-offset) 4)))

(defun html-show-toc ()
  "Shows a TOC based on headings tags <H[1-6]>"
  (interactive)
  (if sgml-tags-invisible
      (error "SGML tags are invisible")
    (occur "<h[1-6]>")
    (pop-to-buffer "*Occur*")
    (vc-toggle-read-only)
    (goto-char (point-min))
    (replace-string "<h1>" "")
    (goto-char (point-min))
    (replace-string "<h2>" "  ")
    (goto-char (point-min))
    (replace-string "<h3>" "    ")
    (goto-char (point-min))
    (replace-string "<h4>" "      ")
    (goto-char (point-min))
    (replace-string "<h5>" "        ")
    (goto-char (point-min))
    (replace-string "<h6>" "          ")
    (goto-char (point-min))
    (replace-regexp "</h[1-6]>" "")
    (goto-char (point-min))
    (toggle-read-only 1)))

(defun html-end-of-line ()
  "If there is an HTML tag at the end of the line, then go to start of tag.
 Otherwise go to the real end of the line."
  (interactive)
  (if (or (looking-at ".*>$") ; if we're on a line that ends with a tag
          (and (= (char-before) 62)
               (= (point) (save-excursion
                            (end-of-line)
                            (point))))) ; or we're at the end of a line
                                        ; with a tag
      (let ((where-now (point)))
        (narrow-to-region
         (save-excursion
           (beginning-of-line)
           (point))
         (save-excursion
           (end-of-line)
           (point)))
        (end-of-line)
        (re-search-backward "<" nil t)
        (if (= (point) where-now)
            (end-of-line))
        (widen))
    (end-of-line)))

(add-hook 'html-helper-mode-hook
          (lambda ()
            (define-key html-helper-mode-map "\C-e" 'html-end-of-line)))

4 Backup control

;; Instea of putting *~ backups in current directory,
;; put them in local .saves
(setq backup-directory-alist `(("." . ".saves")))

;; Just to stop spamming backup files
(setq delete-old-versions t
      kept-new-versions 6
      kept-old-versions 2
      version-control t)

5 Display control

5.1 Hide top bar

(menu-bar-mode -1)

5.2 Line numbers

(setq linum-format "%4d  ")
(global-linum-mode 1)

5.3 Scrolling

(setq redisplay-dont-pause t
      scroll-margin 1
      scroll-step 1
      scroll-conservatively 10000
      scroll-preserve-screen-position 1)

5.4 Silence annoying bell

(setq ring-bell-function 'ignore)

5.5 Character limit in Org-Mode

(add-hook 'org-mode-hook '(lambda () (setq fill-column 80)))
(add-hook 'org-mode-hook 'turn-on-auto-fill)

5.6 Pair the braces

(require 'autopair)
(autopair-global-mode)

5.7 Open shell on F1

(global-set-key (kbd "<f1>") 'shell)

5.8 Show Paren Mode

(show-paren-mode 1)
(setq show-paren-delay 0)

5.9 Disable validate link in HTML

(setq org-html-validation-link nil)

5.10 Window management

(global-set-key (kbd "C-x <up>") 'windmove-up)
(global-set-key (kbd "C-x <down>") 'windmove-down)
(global-set-key (kbd "C-x <left>") 'windmove-left)
(global-set-key (kbd "C-x <right>") 'windmove-right)

5.11 Go to line preview

(global-set-key [remap goto-line] 'goto-line-preview)

6 LSP

;; Give emacs some RAW power, yes
(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 1024 1024)) ;; 1mb

;; Configure LSP-UI by https://emacs-lsp.github.io/lsp-ui/
;; Optional - provides fancier overlays.
(use-package lsp-ui
  :ensure t
  :commands lsp-ui-mode)

;; Sideline options
(setq lsp-ui-sideline-show-diagnostics t)
(setq lsp-ui-sideline-show-hover nil)
(setq lsp-ui-sideline-show-code-actions t)
(setq lsp-ui-sideline-update-mode nil)

(use-package lsp-mode
  :hook ((go-mode . lsp)
         (rust-mode . lsp)
         (c++-mode . lsp)
         (c-mode . lsp)
         (js-mode . lsp)
         (html-mode . lsp)
         (python-mode . lsp)
         (haskell-mode . lsp)
         (js-mode . lsp)
         (lsp-mode . lsp-enable-which-key-integration))
  :commands lsp)

(use-package lsp-pyright
  :ensure t
  :hook (python-mode . (lambda ()
                         (require 'lsp-pyright)
                         (lsp))))  ; or lsp-deferred

(setq lsp-keymap-prefix "C-c l")

(global-set-key (kbd"C-c f") 'lsp-find-definition)

;; Optional - provides snippet support.
(use-package yasnippet
  :ensure t
  :commands yas-minor-mode
  :hook ((go-mode . yas-minor-mode)
         (c++-mode . yas-minor-mode)))

;; Set up before-save hooks to format buffer and add/delete imports.
;; Make sure you don't have other gofmt/goimports hooks enabled.
(defun lsp-go-install-save-hooks ()
  (add-hook 'before-save-hook #'lsp-format-buffer t t)
  (add-hook 'before-save-hook #'lsp-organize-imports t t))
(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)

(lsp-register-custom-settings
 '(("gopls.completeUnimported" t t)
   ("gopls.staticcheck" t t)))

;;Company mode is a standard completion package that works well with lsp-mode.
;;company-lsp integrates company mode completion with lsp-mode.
;;completion-at-point also works out of the box but doesn't support snippets.

(use-package company
  :ensure t
  :config
  (setq company-idle-delay 0)
  (setq company-minimum-prefix-length 1)
  :bind ("M-<tab>" . company-complete))

(use-package company-lsp
  :ensure t
  :commands company-lsp)

(require 'company-box)
(add-hook 'company-mode-hook 'company-box-mode)
(custom-set-faces
 '(company-tooltip ((t (:background "black" :foreground "white"))))
 '(company-tooltip-selection ((t (:background "plum1" :foreground "black")))))

7 Dashboard

;; Enable dashboard
(require 'dashboard)
;; Add the hook
(dashboard-setup-startup-hook)
;; Set the dashboard as the default buffer
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
;; Set the title
(setq dashboard-banner-logo-title "Sandy's Emacs")
;; Set the banner
(setq dashboard-startup-banner 'logo)
(setq dashboard-show-shortcuts nil)
(setq dashboard-week-agenda nil)
(setq dashboard-items '((recents  . 5)
                        (projects . 5)))
(setq dashboard-set-heading-icons t)

8 Magit

Press C-x g to open magit

(global-set-key (kbd "C-x g") 'magit-status)

9 TRAMP

;; Default to ssh when using tramp
(setq tramp-default-method "ssh")

10 M-x Autocomplete

;; Fuzzy command complete on M-x
(global-set-key (kbd "M-x") 'smex)

11 Default theme

;; I like lush and use it by default
(load-theme 'lush t)

12 Chef

(setq org-capture-templates
      '(("c" "Cookbook" entry (file "~/org/cookbook.org")
         "%(org-chef-get-recipe-from-url)"
         :empty-lines 1)
        ("m" "Manual Cookbook" entry (file "~/org/cookbook.org")
         "* %^{Recipe title: }\n  :PROPERTIES:\n  :source-url:\n  :servings:\n  :prep-time:\n  :cook-time:\n  :ready-in:\n  :END:\n** Ingredients\n   %?\n** Directions\n\n")))

13 Org mode

(setq org-startup-folded t)

;; Add the Unicode bullets package
(require 'org-bullets)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))

;; Add timestamp when marked DONE
(setq org-log-done 'time)

;; Use org-ref
(setenv "PATH" (concat (getenv "PATH") ":/Library/TeX/texbin"))
(setenv "PATH" (concat (getenv "PATH") ":/Users/thecsw/Library/Python/3.9/bin"))
(require 'org)
(require 'ox-latex)
(add-to-list 'org-latex-packages-alist '("" "minted"))
(setq org-latex-listings 'minted)

(setq org-latex-custom-lang-environments
      '(
        (emacs-lisp "common-lispcode")
        ))
(setq org-latex-minted-options
      '(("frame" "lines")
        ("fontsize" "\\scriptsize")
        ;;   ("linenos" "")
        ("obeytabs" "")
        ("mathescape" "")
        ("numbersep" "5pt")
        ("numbersep" "2mm")
        ("xleftmargin" "0.25in")))

;; Build nonstopmode with xelatex
(setq org-latex-pdf-process
      '("xelatex -shell-escape -interaction nonstopmode -output-directory %o %b %f"
        "bibtex %b"
        "makeindex %b"
        "xelatex -shell-escape -interaction nonstopmode -output-directory %o %b %f"
        "xelatex -shell-escape -interaction nonstopmode -output-directory %o %b %f"))

(setq org-src-fontify-natively t)

(org-babel-do-load-languages
 'org-babel-load-languages
 '((R . t)
   (latex . t)))

14 Git messenger

;; Press C-c c to open git-messenge
(global-set-key (kbd "C-c c") 'git-messenger:popup-message)
(custom-set-variables
 '(git-messenger:use-magit-popup t))

15 Olivetti

(setq olivetti-body-width 80)

16 Emojify

(add-hook 'after-init-hook #'global-emojify-mode)

17 Ripgrep

(global-set-key (kbd "<f5>") #'deadgrep)

18 Anzu search

(global-anzu-mode +1)

19 Artist

(put 'narrow-to-region 'disabled nil)

20 Which key

(which-key-mode)

21 Projectile

(projectile-mode +1)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)

22 Gemini protocol

(add-hook 'gemini-mode-hook '(lambda () (setq fill-column 80)))
(add-hook 'gemini-mode-hook 'turn-on-auto-fill)

23 LaTeX in org

(setq org-highlight-latex-and-related '(latex script entities))

(add-to-list 'org-latex-classes
             '("sandy-article"
               "\\documentclass[12pt]{article}
\\usepackage{graphicx}
\\usepackage{grffile}
\\usepackage{longtable}
\\usepackage{wrapfig}
\\usepackage{rotating}
\\usepackage[normalem]{ulem}
\\usepackage{amsmath}
\\usepackage{textcomp}
\\usepackage{amssymb}
\\usepackage{capt-of}
\\usepackage{hyperref}
\\usepackage{minted}
\\usepackage{amsmath}
\\usepackage{amssymb}
\\usepackage{setspace}
\\usepackage{subcaption}
\\usepackage{mathtools}
\\usepackage{xfrac}
\\usepackage[margin=1.25in]{geometry}
\\usepackage[utf8]{inputenc}
\\usepackage{color}
\\usepackage{epsf}
\\usepackage{tikz}
\\usepackage{graphicx}
\\usepackage{pslatex}
\\usepackage{hyperref}
\\usepackage[adobe-utopia]{mathdesign}
\\usepackage{helvet}
\\renewcommand{\\familydefault}{\\sfdefault}
\\usepackage{textgreek}
\\renewcommand*{\\textgreekfontmap}{%
{phv/*/*}{LGR/neohellenic/*/*}%
{*/b/n}{LGR/artemisia/b/n}%
{*/bx/n}{LGR/artemisia/bx/n}%
{*/*/n}{LGR/artemisia/m/n}%
{*/b/it}{LGR/artemisia/b/it}%
{*/bx/it}{LGR/artemisia/bx/it}%
{*/*/it}{LGR/artemisia/m/it}%
{*/b/sl}{LGR/artemisia/b/sl}%
{*/bx/sl}{LGR/artemisia/bx/sl}%
{*/*/sl}{LGR/artemisia/m/sl}%
{*/*/sc}{LGR/artemisia/m/sc}%
{*/*/sco}{LGR/artemisia/m/sco}%
}
\\makeatletter
\\newcommand*{\\rom}[1]{\\expandafter\\@slowromancap\\romannumeral #1@}
\\makeatother
\\DeclarePairedDelimiterX{\\infdivx}[2]{(}{)}{%
#1\\;\\delimsize\\|\\;#2%
}
\\newcommand{\\infdiv}{D\\infdivx}
\\DeclarePairedDelimiter{\\norm}{\\left\\lVert}{\\right\\rVert}
\\DeclarePairedDelimiter{\\ceil}{\\left\\lceil}{\\right\\rceil}
\\DeclarePairedDelimiter{\\floor}{\\left\\lfloor}{\\right\\rfloor}
\\def\\Z{\\mathbb Z}
\\def\\R{\\mathbb R}
\\def\\C{\\mathbb C}
\\def\\N{\\mathbb N}
\\def\\Q{\\mathbb Q}
\\def\\noi{\\noindent}
\\onehalfspace
\\usemintedstyle{bw}
[NO-DEFAULT-PACKAGES]
[NO-PACKAGES]"
               ("\\section{%s}" . "\\section*{%s}")
               ("\\subsection{%s}" . "\\subsection*{%s}")
               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
               ("\\paragraph{%s}" . "\\paragraph*{%s}")
               ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

24 Default GUI font

;;;(set-frame-font "InputMono 10" nil t)
(set-face-attribute 'default nil :height 130)

25 Syntax highlight

(add-hook 'after-init-hook 'global-color-identifiers-mode)

26 MacOS stuff

(when (memq window-system '(mac ns x))
  (exec-path-from-shell-initialize))

27 Nano

;; ---------------------------------------------------------------------
;; GNU Emacs / N Λ N O - Emacs made simple
;; Copyright (C) 2020 - N Λ N O developers
;;
;; 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/>.
;; ---------------------------------------------------------------------

(setq default-frame-alist
      (append (list
               '(font . "Monaco:style=Light:size=13")
               ;; '(font . "Roboto Mono Emacs Regular:size=14")
               '(min-height . 1)  '(height     . 40)
               '(min-width  . 1) '(width      . 95)
               '(vertical-scroll-bars . nil)
               '(internal-border-width . 30)
               '(left-fringe    . 0)
               '(right-fringe   . 0)
               '(tool-bar-lines . 0)
               '(menu-bar-lines . 0))))

;; on OSX, type the line below (in terminal) to get a 1 pixel border
;; defaults write com.apple.universalaccess increaseContrast -bool YES

;; To control anti-aliasing on OSX:
;; defaults write org.gnu.Emacs AppleFontSmoothing -int 0 (none)
;; defaults write org.gnu.Emacs AppleFontSmoothing -int 1 (light)
;; defaults write org.gnu.Emacs AppleFontSmoothing -int 2 (medium)
;; defaults write org.gnu.Emacs AppleFontSmoothing -int 3 (strong)


;; Fix bug on OSX in term mode & zsh (spurious % after each command)
(add-hook 'term-mode-hook
          (lambda () (setq buffer-display-table (make-display-table))))

(setq inhibit-startup-screen t
      inhibit-startup-message t
      inhibit-startup-echo-area-message t
      initial-scratch-message nil)
(tool-bar-mode 0)
(tooltip-mode 0)
(menu-bar-mode 0)
;; (global-hl-line-mode 1)
(setq x-underline-at-descent-line t)

;; Vertical window divider
(setq window-divider-default-right-width 1)
(setq window-divider-default-places 'right-only)
(window-divider-mode 1)

;; No ugly button for checkboxes
(setq widget-image-enable nil)

;; Hide org markup for README
(setq org-hide-emphasis-markers t)

28 Company

(eval-after-load 'company
  '(push 'company-robe company-backends))

29 ox5 export (contrib)

29.1 source

;;; ox-s5.el --- S5 Presentation Back-End for Org Export Engine

;; Copyright (C) 2011-2014  Rick Frankel

;; Author: Rick Frankel <emacs at rickster dot com>
;; Keywords: outlines, hypermedia, S5, wp

;; This file is not part of GNU Emacs.

;; 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/>.

     ;;; Commentary:

;; This library implements an S5 Presentation back-end for the Org
;; generic exporter.

;; Installation
;; ------------
;; Get the s5 scripts from
;;    http://meyerweb.com/eric/tools/s5/
;; (Note that the default s5 version is set for using the alpha, 1.2a2.
;; Copy the ui dir to somewhere reachable from your published presentation
;; The default (`org-s5-ui-url') is set to "ui" (e.g., in the
;; same directory as the html file).

;; Usage
;; -----
;; Follow the general instructions at the above website. To generate
;; incremental builds, you can set the HTML_CONTAINER_CLASS on an
;; object to "incremental" to make it build. If you want an outline to
;; build, set the :INCREMENTAL property on the parent headline.

;; To test it, run:
;;
;;   M-x org-s5-export-as-html
;;
;; in an Org mode buffer.  See ox.el and ox-html.el for more details
;; on how this exporter works.

;; TODOs
;; ------
;; The title page is formatted using format-spec.  This is error prone
;; when details are missing and may insert empty tags, like <h2></h2>,
;; for missing values.

(require 'ox-html)
(eval-when-compile (require 'cl))

(org-export-define-derived-backend 's5 'html
  :menu-entry
  '(?s "Export to S5 HTML Presentation"
       ((?H "To temporary buffer" org-s5-export-as-html)
        (?h "To file" org-s5-export-to-html)
        (?o "To file and open"
            (lambda (a s v b)
              (if a (org-s5-export-to-html t s v b)
                (org-open-file (org-s5-export-to-html nil s v b)))))))
  :options-alist
  '((:html-link-home "HTML_LINK_HOME" nil nil)
    (:html-link-up "HTML_LINK_UP" nil nil)
    (:s5-postamble "S5_POSTAMBLE" nil org-s5-postamble newline)
    (:s5-preamble "S5_PREAMBLE" nil org-s5-preamble newline)
    (:html-head-include-default-style "HTML_INCLUDE_DEFAULT_STYLE" nil nil)
    (:html-head-include-scripts "HTML_INCLUDE_SCRIPTS" nil nil)
    (:s5-version "S5_VERSION" nil org-s5-version)
    (:s5-theme-file "S5_THEME_FILE" nil org-s5-theme-file)
    (:s5-ui-url "S5_UI_URL" nil org-s5-ui-url)
    (:s5-default-view "S5_DEFAULT_VIEW" nil org-s5-default-view)
    (:s5-control-visibility "S5_CONTROL_VISIBILITY" nil
                            org-s5-control-visibility))
  :translate-alist
  '((headline . org-s5-headline)
    (plain-list . org-s5-plain-list)
    (inner-template . org-s5-inner-template)
    (template . org-s5-template)))

(defgroup org-export-s5 nil
  "Options for exporting Org mode files to S5 HTML Presentations."
  :tag "Org Export S5"
  :group 'org-export-html)

(defcustom org-s5-version "1.2a2"
  "Version of s5 being used (for version metadata.) Defaults to
     s5 v2 alpha 2.
     Can be overridden with S5_VERSION."
  :group 'org-export-s5
  :type 'string)

(defcustom org-s5-theme-file nil
  "Url to S5 theme (slides.css) file. Can be overridden with the
     S5_THEME_FILE property. If nil, defaults to
     `org-s5-ui-url'/default/slides.css. If it starts with anything but
     \"http\" or \"/\", it is used as-is. Otherwise the link in generated
     relative to `org-s5-ui-url'.
     The links for all other required stylesheets and scripts will be
     generated relative to `org-s5-ui-url'/default."
  :group 'org-export-s5
  :type 'string)

(defcustom org-s5-ui-url "/ui"
  "Base url to directory containing S5 \"default\" subdirectory
     and the \"s5-notes.html\" file.
     Can be overridden with the S5_UI_URL property."
  :group 'org-export-s5
  :type 'string)

(defcustom org-s5-default-view 'slideshow
  "Setting for \"defaultView\" meta info."
  :group 'org-export-s5
  :type '(choice (const slideshow) (const outline)))

(defcustom org-s5-control-visibility 'hidden
  "Setting for \"controlVis\" meta info."
  :group 'org-export-s5
  :type '(choice (const hidden) (const visibile)))

(defvar org-s5--divs
  '((preamble  "div" "header")
    (content   "div" "content")
    (postamble "div" "footer"))
  "Alist of the three section elements for HTML export.
     The car of each entry is one of 'preamble, 'content or 'postamble.
     The cdrs of each entry are the ELEMENT_TYPE and ID for each
     section of the exported document.

     If you set `org-html-container-element' to \"li\", \"ol\" will be
     uses as the content ELEMENT_TYPE, generating an XOXO format
     slideshow.

     Note that changing the preamble or postamble will break the
     core S5 stylesheets.")

(defcustom org-s5-postamble "<h1>%a - %t</h1>"
  "Preamble inserted into the S5 layout section.
     When set to a string, use this string as the postamble.

     When set to a function, apply this function and insert the
     returned string.  The function takes the property list of export
     options as its only argument.

     Setting the S5_POSTAMBLE option -- or the :s5-postamble in publishing
     projects -- will take precedence over this variable.

     Note that the default css styling will break if this is set to nil
     or an empty string."
  :group 'org-export-s5
  :type '(choice (const :tag "No postamble" "&#x20;")
                 (string :tag "Custom formatting string")
                 (function :tag "Function (must return a string)")))

(defcustom org-s5-preamble "&#x20;"
  "Peamble inserted into the S5 layout section.

     When set to a string, use this string as the preamble.

     When set to a function, apply this function and insert the
     returned string.  The function takes the property list of export
     options as its only argument.

     Setting S5_PREAMBLE option -- or the :s5-preamble in publishing
     projects -- will take precedence over this variable.

     Note that the default css styling will break if this is set to nil
     or an empty string."
  :group 'org-export-s5
  :type '(choice (const :tag "No preamble" "&#x20;")
                 (string :tag "Custom formatting string")
                 (function :tag "Function (must return a string)")))

(defcustom org-s5-title-slide-template
  "<h1>%t</h1>
     <h2>%s</h2>
     <h2>%a</h2>
     <h3>%e</h3>
     <h4>%d</h4>"
  "Format template to specify title page section.
     See `org-html-postamble-format' for the valid elements which
     can be included.

     It will be wrapped in the element defined in the :html-container
     property, and defaults to the value of `org-html-container-element',
     and have the id \"title-slide\"."
  :group 'org-export-s5
  :type 'string)

(defun org-s5--format-toc-headline (headline info)
  "Return an appropriate table of contents entry for HEADLINE.
     Note that (currently) the S5 exporter does not support deep links,
     so the table of contents is not \"active\".
     INFO is a plist used as a communication channel."
  (let* ((headline-number (org-export-get-headline-number headline info))
         (section-number
          (and (not (org-export-low-level-p headline info))
               (org-export-numbered-headline-p headline info)
               (concat (mapconcat 'number-to-string headline-number ".") ". ")))
         (tags (and (eq (plist-get info :with-tags) t)
                    (org-export-get-tags headline info))))
    (concat section-number
            (org-export-data
             (org-export-get-alt-title headline info) info)
            (and tags "&nbsp;&nbsp;&nbsp;") (org-html--tags tags info))))

(defun org-s5-toc (depth info)
  (let* ((headlines (org-export-collect-headlines info depth))
         (toc-entries
          (mapcar (lambda (headline)
                    (cons (org-s5--format-toc-headline headline info)
                          (org-export-get-relative-level headline info)))
                  (org-export-collect-headlines info depth))))
    (when toc-entries
      (concat
       (format "<%s id='table-of-contents' class='slide'>\n"
               (plist-get info :html-container))
       (format "<h1>%s</h1>\n"
               (org-html--translate "Table of Contents" info))
       "<div id=\"text-table-of-contents\">"
       (org-html--toc-text toc-entries)
       "</div>\n"
       (format "</%s>\n" (plist-get info :html-container))))))

(defun org-s5--build-head (info)
  (let* ((dir (plist-get info :s5-ui-url))
         (theme (or (plist-get info :s5-theme-file) "slides.css")))
    (mapconcat
     'identity
     (list
      "<!-- style sheet links -->"
      (mapconcat
       (lambda (list)
         (format
          (concat
           "<link rel='stylesheet' href='%s/%s' type='text/css'"
           " media='%s' id='%s' />")
          dir (nth 0 list) (nth 1 list) (nth 2 list)))
       (list
        '("outline.css" "screen" "outlineStyle")
        '("print.css" "print" "slidePrint")
        '("opera.css" "projection" "operaFix")) "\n")
      (format (concat
               "<link rel='stylesheet' href='%s' type='text/css'"
               " media='screen' id='slideProj' />")
              (if (string-match-p "^\\(http\\|/\\)" theme) theme
                (concat dir "/" theme)))
      "<!-- S5 JS -->"
      (concat
       "<script src='" dir
       "/slides.js' type='text/javascript'></script>")) "\n")))

(defun org-s5--build-meta-info (info)
  (concat
   (org-html--build-meta-info info)
   (format "<meta name=\"version\" content=\"S5 %s\" />\n"
           (plist-get info :s5-version))
   (format "<meta name='defaultView' content='%s' />\n"
           (plist-get info :s5-default-view))
   (format "<meta name='controlVis' content='%s' />"
           (plist-get info :s5-control-visibility))))

(defun org-s5-headline (headline contents info)
  (let ((org-html-toplevel-hlevel 1)
        (class (or (org-element-property :HTML_CONTAINER_CLASS headline) ""))
        (level (org-export-get-relative-level headline info)))
    (when (and (= 1 level) (not (string-match-p "\\<slide\\>" class)))
      (org-element-put-property headline :HTML_CONTAINER_CLASS (concat class " slide")))
    (org-html-headline headline contents info)))

(defun org-s5-plain-list (plain-list contents info)
  "Transcode a PLAIN-LIST element from Org to HTML.
     CONTENTS is the contents of the list.  INFO is a plist holding
     contextual information.
     If a containing headline has the property :INCREMENTAL,
     then the \"incremental\" class will be added to the to the list,
     which will make the list into a \"build\"."
  (let* ((type (org-element-property :type plain-list))
         (tag (cl-case type
                (ordered "ol")
                (unordered "ul")
                (descriptive "dl"))))
    (format "%s\n%s%s"
            (format
             "<%s class='org-%s%s'>" tag tag
             (if (org-export-get-node-property :INCREMENTAL plain-list t)
                 " incremental" ""))
            contents
            (format "</%s>" tag))))

(defun org-s5-inner-template (contents info)
  "Return body of document string after HTML conversion.
     CONTENTS is the transcoded contents string.  INFO is a plist
     holding export options."
  (concat contents "\n"))

(defun org-s5-template (contents info)
  "Return complete document string after HTML conversion.
     CONTENTS is the transcoded contents string.  INFO is a plist
     holding export options."
  (let ((info (plist-put
               (plist-put
                (plist-put info :html-preamble (plist-get info :s5-preamble))
                :html-postamble
                (plist-get info :s5-postamble))
               :html-divs
               (if (equal "li" (plist-get info :html-container))
                   (cons '(content "ol" "content") org-s5--divs)
                 org-s5--divs))))
    (mapconcat
     'identity
     (list
      (org-html-doctype info)
      (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">"
              (plist-get info :language) (plist-get info :language))
      "<head>"
      (org-s5--build-meta-info info)
      (org-s5--build-head info)
      (org-html--build-head info)
      (org-html--build-mathjax-config info)
      "</head>"
      "<body>"
      "<div class=\"layout\">"
      "<div id=\"controls\"><!-- no edit --></div>"
      "<div id=\"currentSlide\"><!-- no edit --></div>"
      (org-html--build-pre/postamble 'preamble info)
      (org-html--build-pre/postamble 'postamble info)
      "</div>"
      (format "<%s id=\"%s\" class=\"presentation\">"
              (nth 1 (assq 'content org-html-divs))
              (nth 2 (assq 'content org-html-divs)))
      ;; title page
      (format "<%s id='title-slide' class='slide'>"
              (plist-get info :html-container))
      (format-spec org-s5-title-slide-template (org-html-format-spec info))
      (format "</%s>" (plist-get info :html-container))
      ;; table of contents.
      (let ((depth (plist-get info :with-toc)))
        (when depth (org-s5-toc depth info)))
      contents
      (format "</%s>" (nth 1 (assq 'content org-html-divs)))
      "</body>"
      "</html>\n") "\n")))

(defun org-s5-export-as-html
    (&optional async subtreep visible-only body-only ext-plist)
  "Export current buffer to an HTML buffer.

     If narrowing is active in the current buffer, only export its
     narrowed part.

     If a region is active, export that region.

     A non-nil optional argument ASYNC means the process should happen
     asynchronously.  The resulting buffer should be accessible
     through the `org-export-stack' interface.

     When optional argument SUBTREEP is non-nil, export the sub-tree
     at point, extracting information from the headline properties
     first.

     When optional argument VISIBLE-ONLY is non-nil, don't export
     contents of hidden elements.

     When optional argument BODY-ONLY is non-nil, only write code
     between \"<body>\" and \"</body>\" tags.

     EXT-PLIST, when provided, is a property list with external
     parameters overriding Org default settings, but still inferior to
     file-local settings.

     Export is done in a buffer named \"*Org S5 Export*\", which
     will be displayed when `org-export-show-temporary-export-buffer'
     is non-nil."
  (interactive)
  (org-export-to-buffer 's5 "*Org S5 Export*"
    async subtreep visible-only body-only ext-plist (lambda () (nxml-mode))))

(defun org-s5-export-to-html
    (&optional async subtreep visible-only body-only ext-plist)
  "Export current buffer to a S5 HTML file.

     If narrowing is active in the current buffer, only export its
     narrowed part.

     If a region is active, export that region.

     A non-nil optional argument ASYNC means the process should happen
     asynchronously.  The resulting file should be accessible through
     the `org-export-stack' interface.

     When optional argument SUBTREEP is non-nil, export the sub-tree
     at point, extracting information from the headline properties
     first.

     When optional argument VISIBLE-ONLY is non-nil, don't export
     contents of hidden elements.

     When optional argument BODY-ONLY is non-nil, only write code
     between \"<body>\" and \"</body>\" tags.

     EXT-PLIST, when provided, is a property list with external
     parameters overriding Org default settings, but still inferior to
     file-local settings.

     Return output file's name."
  (interactive)
  (let* ((extension (concat "." org-html-extension))
         (file (org-export-output-file-name extension subtreep))
         (org-export-coding-system org-html-coding-system))
    (org-export-to-file 's5 file
      async subtreep visible-only body-only ext-plist)))

(defun org-s5-publish-to-html (plist filename pub-dir)
  "Publish an org file to S5 HTML Presentation.

     FILENAME is the filename of the Org file to be published.  PLIST
     is the property list for the given project.  PUB-DIR is the
     publishing directory.

     Return output file name."
  (org-publish-org-to 's5 filename ".html" plist pub-dir))

(provide 'ox-s5)

     ;;; ox-s5.el ends here

29.2 theme

(setq org-s5-theme "i18n")        ; the i18n theme by the author of S5

30 Render latex in org mode

(add-hook 'org-mode-hook 'org-fragtog-mode)

31 Better search with ctrlf

(ctrlf-mode +1)

32 Highlight current active line

(global-hl-line-mode +1)

33 Native compilation

(setq package-native-compile t)
;;(native-compile-async "~/.emacs.d/elpa" 'recursively) ;; <-- danger zone

34 Vterm

(add-to-list 'load-path "/Users/thecsw/gits/emacs-libvterm")
(require 'vterm)

35 Telephone line

(require 'telephone-line)

(setq telephone-line-primary-left-separator 'telephone-line-cubed-left
      telephone-line-secondary-left-separator 'telephone-line-cubed-hollow-left
      telephone-line-primary-right-separator 'telephone-line-cubed-right
      telephone-line-secondary-right-separator 'telephone-line-cubed-hollow-right)
(setq telephone-line-height 20
      telephone-line-evil-use-short-tag t)

(telephone-line-mode 1)

36 Neotree

(setq neo-smart-open t)
(global-set-key [f8] 'neotree-toggle)
(setq neo-global--do-autorefresh t)

Date: 23; 12021 H.E.

Author: Sandy Urazayev

Created: 2021-03-01 Mon 05:45