Emacs is old school. You're either new to it - which means you wouldn't be here unless it was your type of thing - or you know what you're looking for. In either case, go to the side bar of this page and click on the 'Emacs' tag. Then read the posts y date from oldest to newest.

In the last emacs post I covered lines 664 - 769. This post covers lines 771 - 914

Today's post covers "entering and exiting Emacs" and "default appearance customizations."

  • Appearance
    • Entering and Exiting Emacs
    • Default Appearance Customizations
    • Themes
    • Highlights
    • Hydras
    • Appearance Hydra

Most of what follows is relevant. If you don't want your Emacs to beep when you hit the end of a file, you need to set a default, and the same for other annoying behaviours.

Of course, I make no promise the following section is efficient. Let me know if you see double entries.

Entering and Exiting Emacs

Dashboard is cool. Gives you an opening screen you can post an image.

(use-package dashboard
:after all-the-icons
:diminish (dashboard-mode page-break-lines-mode)
:load-path dash-p
(require 'dashboard)
(setq dashboard-footer "Time teaches all things.")
(setq dashboard-footer-icon (all-the-icons-octicon "calendar"
                                                   :height 1.1
                                                   :v-adjust -0.05
                                                   :face 'font-lock-keyword-face))
(dashboard-center-content t)
(dashboard-startup-banner dash-image-p)
(dashboard-banner-logo-title "Poseidon Editor")
;(dashboard-startup-banner 3)
(bookmarks . 5)
;(projects . 5)
(recents . 5)
);end a-list
);end dashboard-items
(dashboard-heading ((t (:foreground "#f1fa8c" :weight bold))))
(after-init . dashboard-setup-startup-hook)


Btw, in poseidon configuration "-p", as above in "dash-p," represents a variable containing a path declared earlier in the initialization file. For example 'dash-p' was declared and assigned earlier on line 70 like this: (defvar dash-p "C:/emacs/emax/elpa/dashboard-20190721.504/" )

Dashboard Image

Below is a dashboard image. After Emacs loads, this screen appears, with shortcuts to recent files, or other file categories you have configured.

emacs initialization file image for emacs configuration poseidon

Exit Poseidon

A function to exit emacs. I use it from minibuffer or from a hydra.

;exit and save command-logs,only works if command-log-mode feature is loaded at the same time global-command-log-mode is started
(defun exit-poseidon ()
(if (featurep 'command-log-mode)
);end exit poseidon
; the mnemonic is C-x really quit (close everything)
(bind-key "C-x r q" 'exit-poseidon)

Restart Poseidon

Restart is nifty for trouble-shooting init

(use-package restart-emacs
;(setq restart-emacs-restore-frames t)
(defun restart-poseidon()
(if (featurep 'command-log-mode) (clm/save-command-log)
);end restart-poseidon
("C-x r r" . restart-poseidon)
);end restart-emacs

Default Appearance Customizations: System Info

Puts info and path at top of frame

(setq system-name "Your System Name")
(setq user-full-name "Your Name")
(setq user-mail-address "[email protected]")
;menu-bar, tool-bar, scroll-bar
;(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
;(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(setq display-time-12hr-format t)
(setq display-time-format "%H:%M - %B %d - %Y")
(display-time-mode 1)
;(setq display-time-day-and-date t)
;Put path, time, date at frame top
(setq global-mode-string nil)
(defun frame-title-prefix()
(list (format "%s %%S: %%j " (concat "System: " system-name " - Editor: Poseidon - Path"))
         '(buffer-file-name "%f" (dired-directory dired-directory "%b"))))
(setq frame-title-format
'(" " (:eval (frame-title-prefix)) " - Time and Date: " display-time-string))

Desktop Config

I only use when I have some complex stuff going on and I need to come back to it exactly. It's a bit weird, you need to alternate saves to keep a default opening in reserve.

;save desktop configuration
(use-package desktop+
:commands (desktop-create desktop-load)
(eval-after-load "desktop+"
  '(defun desktop+--set-frame-title ()
(message "desktop+ set in initialization to not write to frame title")
(require 'desktop+)
;if you want to also save open buffers
;(setq desktop+-special-buffer-handlers '(org-agenda-mode shell-mode))
);end desktop+

A few defaults

;inhibit font caching
(setq inhibit-compacting-font-caches t)
;increase/decrease text
(bind-key "C-=" 'text-scale-increase)
(bind-key "C--" 'text-scale-decrease)
;Wrap words at window edge
(setq truncate-partial-width-windows nil)
;(global-visual-line-mode t)
(diminish 'visual-line-mode)

Visual Fill Column and Adaptive Wrap

Visual Fill Column shows a line where words will end. You can change the fill column to fit various page widths. Example, Microsoft Word = ~100.

Adaptive wrap preserves the indent on text wrapping.

;Wrap words at column edge
(use-package visual-fill-column
:commands visual-fill-column-mode
;(add-hook 'visual-line-mode-hook #'visual-fill-column-mode)
(advice-add 'text-scale-increase :after
(advice-add 'text-scale-decrease :after
);end use package fill column

; you need to download adaptive wrap library from somewhere and add a path to it
;adaptive wrap indents wrapped lines
(add-to-list 'load-path adaptive-wrap-p)
(require 'adaptive-wrap)

Coding system

;all the coding systems you can handle (still doesn't always work)
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(set-language-environment 'utf-8)
(setq coding-system-for-read 'utf-8)
(setq coding-system-for-write 'utf-8)
(set-default-coding-systems 'utf-8)
;Replace characters that paste into emacs incorrectly

Replace Garbage Characters

When you cut and paste from the net or other programs the coding systems don't always match. You can find garbage characters on your screen.

I use the following function to replace them. Whenever I meet a new one, I add it below.

(defun replace-garbage-chars ()
"Replace non-rendering MS and other garbage characters with latin1 equivalents."
(save-excursion             ;save the current point
(replace-string "\221" "`" nil (point-min) (point-max))
(replace-string "\222" "'" nil (point-min) (point-max))
(replace-string "\226" "-" nil (point-min) (point-max))
(replace-string "\227" "--" nil (point-min) (point-max))
(replace-string "\223" "(" nil (point-min) (point-max))
(replace-string "\224" ")" nil (point-min) (point-max))
(replace-string "\205" "..." nil (point-min) (point-max))
(replace-string "\225" "-" nil (point-min) (point-max))
(replace-string "\344" "" nil (point-min) (point-max))
(replace-string "\374" "" nil (point-min) (point-max))
(replace-string "\337" "" nil (point-min) (point-max))
(replace-string "\366" "" nil (point-min) (point-max))
(replace-string "\247" "***" nil (point-min) (point-max))
(replace-string "\267" "****" nil (point-min) (point-max))
(replace-string "\351" "é" nil (point-min) (point-max))
(replace-string "\347" "ç" nil (point-min) (point-max))
(replace-string "\352" "ê" nil (point-min) (point-max))
(replace-string "\342" "â" nil (point-min) (point-max))
(replace-string "\307" "Ç" nil (point-min) (point-max))
(replace-string "\340" "à" nil (point-min) (point-max))
(replace-string "\340" "à" nil (point-min) (point-max))
(replace-string "\364" "ô" nil (point-min) (point-max))
(replace-string "\353" "ë" nil (point-min) (point-max))
(replace-string "\243" "£" nil (point-min) (point-max))
));end replace-garbage-characters
;bind-key replace-garbage-characters
(bind-key  "\C-cr"  'replace-garbage-chars)

That’s all for now…