Default Operations

Moving The Cursor and Screen

You can use C-a, C-e, C-n, and C-p to move the cursor around the screen.

Add some defaults to get Emacs working better.



 ; Don't highlight matches with jump-char - it's distracting
(setq jump-char-lazy-highlight-face nil)

; Scroll 1 line at a time
(setq scroll-step 1)

; Save point position between sessions
(require 'saveplace)
(setq-default save-place t)
(setq save-place-file (expand-file-name ".places" save-place-file-p))

;Fix the whole huge-jumps-scrolling-between-windows nastiness
(setq scroll-conservatively 1000)

;"Don't hscroll unless needed"- ? More voodoo lisp.
(setq hscroll-margin 1)

;Keeps cursor in the same relative row during pgups and dwns
(setq scroll-preserve-screen-position t)

;Accelerate the cursor when scrolling.
(load "accel" t)

;;Start scrolling when 2 lines from top/bottom
(setq scroll-margin 8)

;cursor
(blink-cursor-mode 0)

;Push the mouse out of the way when the cursor approaches.
(mouse-avoidance-mode 'jump)

;scroll other window
(bind-key "C-M-n" 'helm-scroll-other-window-down)
(bind-key "C-M-p" 'helm-scroll-other-window)

;backward/forward paragraph
(bind-key "M-p" 'backward-paragraph)
(bind-key "M-n" 'forward-paragraph)

;pop-to-mark-command
(bind-key "C-0" 'pop-to-mark-command)

Smooth-Scrolling


(use-package smooth-scrolling
:config
(require 'smooth-scrolling)
(smooth-scrolling-mode t)
(setq smooth-scroll/vscroll-step-size 1)
(setq smooth-scroll/hscroll-step-size 1)
(setq fast-but-imprecise-scrolling t)
:diminish)

Avy


;Move with M-s
(use-package avy
:bind
("M-s" . avy-goto-char));end avy
;Move by sections of lines rather than lines

Mwim


(use-package mwim
:bind
("C-a" . mwim-beginning-of-code-or-line)
("C-e" . mwim-end-of-code-or-line));end mwim
;beginning end of buffer
(bind-key "<home>" 'beginning-of-buffer)
(bind-key "<end>" 'end-of-buffer)

Delete-All-Other-Buffers



;delete-all-buffers
(defun delete-all-other-buffers ()
  (interactive)
    (mapc 'kill-buffer (cdr (buffer-list (current-buffer)))))

Create a New Scratch Frame in a Buffer



;Create scratch buffer
(defun new-frame-scratch-buffer ()
"Create a new scratch buffer -- \*hello-world\*"
(interactive)
  (let ((n 0)
        bufname buffer)
    (catch 'done
      (while t
        (setq bufname (concat "*hello-world"
          (if (= n 0) "" (int-to-string n))
            "*"))
        (setq n (1+ n))
        (when (not (get-buffer bufname))
          (setq buffer (get-buffer-create bufname))
          (with-current-buffer buffer
            (emacs-lisp-mode))
          ;; When called non-interactively, the `t` targets the other window (if it exists).
          (throw 'done (display-buffer buffer '(display-buffer-pop-up-frame .( (window-height .8) (window-width .8)))
)) )))))

Rotate Windows


; rotate windows
(defun rotate-windows (arg)
  "Rotate your windows; use the prefix argument to rotate the other direction"
  (interactive "P")
  (if (not (> (count-windows) 1))
      (message "You can't rotate a single window!")
    (let* ((rotate-times (prefix-numeric-value arg))
           (direction (if (or (< rotate-times 0) (equal arg '(4)))
                          'reverse 'identity)))
      (dotimes (_ (abs rotate-times))
        (dotimes (i (- (count-windows) 1))
          (let* ((w1 (elt (funcall direction (window-list)) i))
                 (w2 (elt (funcall direction (window-list)) (+ i 1)))
                 (b1 (window-buffer w1))
                 (b2 (window-buffer w2))
                 (s1 (window-start w1))
                 (s2 (window-start w2))
                 (p1 (window-point w1))
                 (p2 (window-point w2)))
            (set-window-buffer-start-and-point w1 b2 s2 p2)
            (set-window-buffer-start-and-point w2 b1 s1 p1)))))))

; to make a new scratch buffer in a new frame
 (bind-key "C-c b" 'new-frame-scratch-buffer)
 ;to kill a frame in emacs (also, C-x 0)
 (bind-key "C-x C-c" 'delete-frame)
 ;make a new frame
 (bind-key "C-x C-n" 'make-frame-command)

Frame-CMDS



;Copy/p frame-cmds.el & frame-fnc.el to frame-cmds directory
 (require 'frame-cmds)
 (bind-key "M-S-<up>" 'move-frame-up)
 (bind-key "M-S-<right>" 'move-frame-right)
 (bind-key "M-S-<down>" 'move-frame-down)
 (bind-key "M-S-<left>" 'move-frame-left)
 (bind-key "C-M-<up>" 'enlarge-frame)
 (bind-key "C-M-<right>" 'enlarge-frame-horizontally)
 (bind-key "C-M-<down>" 'shrink-frame)
 (bind-key "C-M-<left>" 'shrink-frame-horizontally)

Switch Window



;Switch Windows
(use-package switch-window
:defer t
:config
(setq switch-window-input-style 'minibuffer
      switch-window-threshold 2
      switch-window-increase 4
      switch-window-shortcut-style 'qwerty
      switch-window-qwerty-shortcuts '("f" "k" "j" "d" "s" "l")
      switch-window-auto-resize-window t
      switch-window-default-window-size 0.6)
:bind
([remap other-window] . switch-window)
);end switch window

Shrink Window



;enlarge/shrink window
(bind-key "C-<up>" 'enlarge-window)
(bind-key "C-<down>" 'shrink-window)
;hydra-buffers-frames

Buffers Hydra



;define a title function
(defvar frames-buffers-title (with-faicon "clone" "FRAMES AND BUFFERS"))
;generate hydra
(pretty-hydra-define Frames-Buffers (:foreign-keys warn :title frames-buffers-title :quit-key "q" :color pink )
("Delete, Make and Switch"
   (("d"  delete-all-other-buffers "Delete All Other Buffers")
    ("f"  delete-frame "Delete This Frame" )
    ("F"  delete-other-frames "Delete All Other Frames" )
    ("s"  new-frame-scratch-buffer "Make New Scratch Frame" )
    ("m"  make-frame-command "Open A New Frame")
    ("o"  switch-window "Switch To Other Window")
    ("r"  rotate-windows "Rotate Windows")
);end delete

"Move Frames And Windows"
   (
    ("U"   move-frame-up "Move Up M-S-<up>")
    (">"   move-frame-right "Move Right M-S-<right>")
    ("D"   move-frame-down "Move Down M-S-<down>" )
    ("<"   move-frame-left "Move Left M-S-<left>" )
    ("E"   enlarge-frame-horizontally "Horizontal Grow  C-M-<right>")
    ("L"   shrink-frame-horizontally "Horizontal Shrink C-M-<left>" )
     ) ;end Move frames and windows

"EXIT"
  (  ("G"   enlarge-frame  "Enlarge Frame C-M-<up>"   )
    ("g"   shrink-frame "Shrink Frame C-M-<down>" )
    ("W"  enlarge-window  "Enlarge Window C-<up>" )
    ("w"  shrink-window   " Shrink Window C-<down>")
    ("h" hydra-helm/body "Return To Helm" :color blue )
    ("<SPC>" nil "Quit" :color blue )
);end exit
);end hydra body
);end pretty-hydra-appearance
(bind-key "<C-m> f" 'Frames-Buffers/body)