init-gui-frames.org 8.7 KB

Don't show the tool bar. It's a waste of space


(when (fboundp 'tool-bar-mode)
  (tool-bar-mode -1))

windmove

(use-package windmove )

Windmove makes it easy to move point to a different buffer, especially when the window displays more than 1 buffer.

This might be a good thing for a hydra here.

Windmove doesn't have a toggle window split. I found this command online.


(defun my/toggle-window-split ()
  (interactive)
  (if (= (count-windows) 2)
      (let* ((this-win-buffer (window-buffer))
             (next-win-buffer (window-buffer (next-window)))
             (this-win-edges (window-edges (selected-window)))
             (next-win-edges (window-edges (next-window)))
             (this-win-2nd (not (and (<= (car this-win-edges)
                                         (car next-win-edges))
                                     (<= (cadr this-win-edges)
                                         (cadr next-win-edges)))))
             (splitter
              (if (= (car this-win-edges)
                     (car (window-edges (next-window))))
                  'split-window-horizontally
                'split-window-vertically)))
        (delete-other-windows)
        (let ((first-win (selected-window)))
          (funcall splitter)
          (if this-win-2nd (other-window 1))
          (set-window-buffer (selected-window) this-win-buffer)
          (set-window-buffer (next-window) next-win-buffer)
          (select-window first-win)
          (if this-win-2nd (other-window 1))))))

I think that some of these commands are not needed.



  (with-eval-after-load 'evil
    (define-key evil-emacs-state-map (kbd "C-w h") 'windmove-down)
    (define-key evil-emacs-state-map (kbd "C-w t") 'windmove-up)
    (define-key evil-emacs-state-map (kbd "C-w n") 'windmove-left)
    (define-key evil-emacs-state-map (kbd "C-w s") 'windmove-right)
    (define-key evil-emacs-state-map (kbd "C-w C-t") 'my/toggle-window-split)

    (define-key evil-window-map (kbd "C-t") 'my/toggle-window-split)
    (define-key evil-emacs-state-map (kbd "C-w C-t") 'my/toggle-window-split)

    (evil-define-key 'emacs evil-normal-state-map (kbd "C-w h") 'windmove-down)
    (evil-define-key 'emacs evil-normal-state-map (kbd "C-w t") 'windmove-up)
    (evil-define-key 'emacs evil-normal-state-map (kbd "C-w n") 'windmove-left)
    (evil-define-key 'emacs evil-normal-state-map (kbd "C-w s") 'windmove-ri)
    (evil-define-key 'emacs evil-normal-state-map (kbd "C-w C-t") 'my/toggle-window-split)

    ;;I don't think this would ever really be useful
    (evil-define-key 'normal help-mode-map (kbd "C-w h") 'windmove-down)
    (evil-define-key 'normal help-mode-map (kbd "C-w t") 'windmove-up)
    (evil-define-key 'normal help-mode-map (kbd "C-w n") 'windmove-left)
    (evil-define-key 'normal help-mode-map (kbd "C-w s") 'windmove-right)
    (evil-define-key 'normal help-mode-map (kbd "C-w C-t") 'my/toggle-window-split)

    (evil-define-key 'emacs  help-mode-map (kbd "C-w h") 'windmove-down)
    (evil-define-key 'emacs  help-mode-map (kbd "C-w t") 'windmove-up)
    (evil-define-key 'emacs  help-mode-map (kbd "C-w n") 'windmove-left)
    (evil-define-key 'emacs  help-mode-map (kbd "C-w s") 'windmove-right)
    (evil-define-key 'emacs  help-mode-map (kbd "C-w C-t") 'my/toggle-window-split)

    (evil-define-key 'normal debugger-mode-map (kbd "C-w h") 'windmove-down)
    (evil-define-key 'normal debugger-mode-map (kbd "C-w t") 'windmove-up)
    (evil-define-key 'normal debugger-mode-map (kbd "C-w n") 'windmove-left)
    (evil-define-key 'normal debugger-mode-map (kbd "C-w s") 'windmove-right)
    (evil-define-key 'normal debugger-mode-map (kbd "C-w C-t") 'my/toggle-window-split)

    (evil-define-key 'emacs  debugger-mode-map (kbd "C-w h") 'windmove-down)
    (evil-define-key 'emacs  debugger-mode-map (kbd "C-w t") 'windmove-up)
    (evil-define-key 'emacs  debugger-mode-map (kbd "C-w n") 'windmove-left)
    (evil-define-key 'emacs  debugger-mode-map (kbd "C-w s") 'windmove-right)
    (evil-define-key 'emacs  debugger-mode-map (kbd "C-w C-t") 'my/toggle-window-split)

    (evil-define-key 'emacs  erc-mode-map (kbd "C-w h") 'windmove-down)
    (evil-define-key 'emacs  erc-mode-map (kbd "C-w t") 'windmove-up)
    (evil-define-key 'emacs  erc-mode-map (kbd "C-w n") 'windmove-left)
    (evil-define-key 'emacs  erc-mode-map (kbd "C-w s") 'windmove-right)
    (evil-define-key 'emacs  erc-mode-map (kbd "C-w C-t") 'my/toggle-window-split)

    (evil-define-key 'emacs  gnus-article-mode-map (kbd "C-w h") 'windmove-down)
    (evil-define-key 'emacs  gnus-article-mode-map (kbd "C-w t") 'windmove-up)
    (evil-define-key 'emacs  gnus-article-mode-map (kbd "C-w n") 'windmove-left)
    (evil-define-key 'emacs  gnus-article-mode-map (kbd "C-w s") 'windmove-right)
    (evil-define-key 'emacs  gnus-article-mode-map (kbd "C-w C-t") 'my/toggle-window-split))

This lets you use the windmove commands inside an info buffer!!!! sooo cool! #+BEGIN_SRC emacs-lisp (with-eval-after-load 'info (define-key Info-mode-map (kbd "C-w h") 'windmove-down) (define-key Info-mode-map (kbd "C-w t") 'windmove-up) (define-key Info-mode-map (kbd "C-w n") 'windmove-left) (define-key Info-mode-map (kbd "C-w s") 'windmove-right)) #+END_SRC

improving the mouse experience

scroll one line at a time (less "jumpy" than defaults) this lets you scroll the emacs buffer rather smoothly


(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
(setq scroll-step 1) ;; keyboard scroll one line at a time

Open Emacs up like you had it last.

:PROPERTIES: :ID: 720c6d6c-91f8-4894-8072-dcd4d9ffb543 :END: This is SOOO useful! Not really. It conflicts with me wanting to open my org calendar...

Use the desktop library to save the state of Emacs from one session to another. Once you save the Emacs desktop—the buffers, their file names, major modes, buffer positions, and so on—then subsequent Emacs sessions reload the saved desktop. By default, the desktop also tries to save the frame and window configuration. To disable this, set desktop-restore-frames to nil. (See that variable’s documentation for some related options that you can customize to fine-tune this behavior.)


(desktop-save-mode 1)

Save the position point was in

http://whattheemacsd.com/init.el-03.html Save the position that point was in during the last emacs session


(setq save-place-file (expand-file-name ".places" user-emacs-directory))
(save-place-mode)

Highlight cursor's line

show a nice highlight where-ever your cursor is but ONLY on graphical displays. It looks weird in the terminal


  (defun my/turn-on-hl-line-mode ()
    "This will turn on hl-line mode."
    (interactive)
    (when (display-graphic-p)
      (add-hook 'prog-mode-hook 'hl-line-mode)
      (add-hook 'text-mode-hook 'hl-line-mode)))

  (add-hook 'after-init-hook 'my/turn-on-hl-line-mode)

color various comments

make comments in most programming languages various colors.


  ;;cr red
  ;;cg green
  ;;x like this
  (defface font-lock-comment-strike
    '((t (:strike-through t)))
    "For strike-through comments")

  (defface font-lock-comment-important
    '((t (:foreground "#00ff00")))
    "For important")

  (defface font-lock-comment-todo
    '((t (:foreground "#ff0000")))
    "For todo comments")

(defun add-custom-keyw ()
  "adds a few special keywords"
  (font-lock-add-keywords
   nil
   '(("\\s<+x[[:space:]]*\\(.*?\\)[[:space:]]*\\s>" 1 'font-lock-comment-strike prepend)
     ("\\s<+cr[[:space:]]*\\(.*?\\)[[:space:]]*\\s>" 1 'font-lock-comment-todo prepend)
     ("\\s<+cg[[:space:]]*\\(.*?\\)[[:space:]]*\\s>" 1 'font-lock-comment-important prepend))))

    (add-hook 'prog-mode-hook #'add-custom-keyw)


Provide this file


  (provide 'init-gui-frames)