Today's post has some of the default settings from my initialization file.

    • Necessary Adjustments when you set-up on a new computer
    • Paths to Update on Change
    • Executable Paths
    • Libraries
    • Function declarations
    • Emacs Customization Seperate File
    • Emax Defaults
    • Some Defaults
    • Frames, Buffers, And Lines
    • Some Custom Default Functions
    • Some New Key Bindings
    • Popup, Pos-tip,Tooltip, Posframe
    • Which Key


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 customization file and some defaults, lines 425 - 534 of my configuration. This post covers "Frames, Buffers, And Lines" and "Some Custom Default Functions", so lines 534 - 656

Most of this is relevant. If you don't want your Emacs to beep when you hit the end of the file, then you need to set a default, and the same for another annoying stuff. I make no promises the following section is efficient (let me know if you see some double entries).

Frames, Buffers, and Lines

Just more useful defaults.

;set the initial frame, different for each monitor
(setq initial-frame-alist '((left . 250) (top . 25) (height . 40) (width . 110)
(left-fringe . 6) (right-fringe . 6)))
;set default frame
(setq default-frame-alist (copy-alist initial-frame-alist))
;Auto refresh buffers including dired
(setq global-auto-revert-non-file-buffers t)
; Do not generate any messages (be quiet about refreshing Dired).
(setq auto-revert-verbose nil)
;Auto refresh buffers
(global-auto-revert-mode 1)
;encourage new frame over new window
(setq split-window-preferred-function nil)
;(setq split-window-preferred-function 'split-window-sensibly)
;two identical buffers get uniquely numbered names
(require 'uniquify)
;if window smaller 90 split below, over split beside
(setq split-width-threshold 90)
(setq uniquify-buffer-name-style 'forward)
;; Allow recursive minibuffers
(setq enable-recursive-minibuffers t)
;;show recursion depth in minibuffer
(minibuffer-depth-indicate-mode t)
;; Save minibuffer history
(savehist-mode 1)
(setq history-length 1000)
;Killing line deletes it
(setq kill-whole-line t)
;Down arrow won't add \n
(setq next-line-add-newlines t)
;newline required
;(setq require-final-newline t)
;Iterate through CamelCase words diminished
(with-eval-after-load 'subword
  (diminish 'subword-mode))
(global-subword-mode +1)
; Don't break lines
(setq-default truncate-lines t)

More Custom Functions
Go to line

I use it, in a hydra and from the minibuffer.

; go to line with feedback
 (defun goto-line-with-feedback ()
   "Show line numbers temporarily, while prompting for the line number input"
 (display-line-numbers-mode 1)
 (goto-line (read-number "Goto line: ")))
     (display-line-numbers-mode 0)))

Append Lines

Rarely used.

(defun append-lines ()
"add next line to current line"
    (lambda ()
            (join-line -1)))

Open File (from Dired)

I use it a lot.

(defun xah-open-in-external-app (&optional file)
  "Open the current file or dired marked files in external app.
The app is chosen from your OS's preference."
  (let ( doIt
           ((string-equal major-mode "dired-mode") (dired-get-marked-files))
           ((not file) (list (buffer-file-name)))
           (file (list file)))))

    (setq doIt (if (<= (length myFileList) 5)
                 (y-or-n-p "Open more than 5 files? ") ) )
     (when doIt
       ((string-equal system-type "windows-nt")
        (mapc (lambda (fPath) (w32-shell-execute "open" (replace-regexp-in-string "/" "\\" fPath t t)) ) myFileList))
       ((string-equal system-type "darwin")
        (mapc (lambda (fPath) (shell-command (format "open \"%s\"" fPath)) )  myFileList) )
       ((string-equal system-type "gnu/linux")
        (mapc (lambda (fPath) (let ((process-connection-type nil)) (start-process "" nil "xdg-open" fPath)) ) myFileList) ) ) ) ) )

Date and Time Stuff

Good to have around, somewhere. You need this to remember when you hit blue ocean.

;; Date and time functions
(defvar current-date-time-format "%a %b %d %Y %H:%M:%S %Z "
  "Format of date to insert with `insert-current-date-time' func
See help of `format-time-string' for possible replacements")
(defvar current-date-format "%d %b  %Y "
  "Format of date to insert with `insert-current-date-time' func
See help of `format-time-string' for possible replacements")
(defvar current-time-format "%a %H:%M:%S"
  "Format of date to insert with `insert-current-time' func.
Note the weekly scope of the command's precision.")
(defun insert-current-date-time ()
  "insert the current date and time into current buffer.
Uses `current-date-time-format' for the formatting the date/time."
;       (insert (let () (comment-start)))
       (insert (format-time-string current-date-time-format (current-time)))
(defun insert-current-date ()
  "insert the current date and time into current buffer.
Uses `current-date-format' for the formatting the date/time."
;       (insert (let () (comment-start)))
       (insert (format-time-string current-date-format (current-time)))
(defun insert-current-time ()
  "insert the current time (1-week scope) into the current buffer."
       (insert (format-time-string current-time-format (current-time)))
(bind-key "\C-c\C-y" 'insert-current-date)
(bind-key "\C-c\C-t" 'insert-current-time)

That’s all for now…