Entering and Exiting Emacs

Dashboard gives you an opening screen with links and an image.



(use-package dashboard
:after all-the-icons
:diminish (dashboard-mode page-break-lines-mode)
:load-path dash-p
:config
(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))
:custom
(dashboard-center-content t)
(dashboard-setup-startup-hook)
(dashboard-startup-banner dash-image-p)
(dashboard-banner-logo-title "Poseidon Editor")
;(dashboard-startup-banner 3)
(dashboard-items
'(
(bookmarks . 5)
;(projects . 5)
(recents . 5)
);end a-list
);end dashboard-items
:custom-face
(dashboard-heading ((t (:foreground "#b71b48" :weight bold))))
:hook
(after-init . dashboard-setup-startup-hook)
);end-dashboard

Exit

You can write custom functions that run code before Emacs shuts down.



(defun exit-custom ()
(interactive)
(if (featurep 'command-log-mode)
(progn
(clm/save-command-log)
(stop-mpd)
(save-buffers-kill-terminal)
);end progn
);
);end exit poseidon

(bind-key "C-x r q" 'exit-poseidon)

Restart Emacs

With restart-emacs you can debug Emacs.



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

System Info

You can puts info and path at the top of the 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))
;clock
(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

Save your configuration.



;save desktop configuration
(use-package desktop+
:commands (desktop-create desktop-load)
:init
(eval-after-load "desktop+"
  '(defun desktop+--set-frame-title ()
(message "desktop+ set in initialization to not write to frame title")
 ))
:config
(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

You can show a line on the screen after 100 characters.



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

Adaptive Wrap

Adaptive wrap preserves the indent on text wrapping.



; 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 if the coding systems don't match, you can find garbage characters on your screen.

Add the correct characters below to replace the garbage characters.



(defun replace-garbage-chars ()
"Replace non-rendering MS and other garbage characters with latin1 equivalents."
(interactive)
(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)