This file just loads in tiny packages that don't really need to be in separate files.
;; -*- lexical-binding: t -*-
(use-package s)
(use-package dash)
(use-package alert :defer t)
Async uses another Emacs to async-ously execute emacs lisp code.
(use-package async
:defer t
;;:config
;; enable async compilation of melpa packages
;;(async-bytecomp-package-mode 1)
)
Here is an example of what you can do with async.
(async-start
;; What to do in the child process
(lambda ()
(message "This is a test")
(sleep-for 3)
222)
;; What to do when it finishes
(lambda (result)
(message "Async process done, result should be 222: %s" result)))
:PROPERTIES: :ID: 05d87555-d6c3-4bd9-9b2e-158a1deff0f7 :END:
(use-package f :defer t)
;;(require 'f)
With point over one paren, Emacs will highlight both parens.
#+BEGIN_SRC emacs-lisp (add-hook 'prog-mode-hook 'show-paren-mode) #+END_SRC
When you type an open parenthsis, electric pair mode types the second one for you, leaving point between them.
#+BEGIN_SRC emacs-lisp (add-hook 'prog-mode-hook 'electric-pair-mode) ;;(electric-pair-mode t) #+END_SRC
Each pair of parenthesis-es will have different colors. This can aid in discovering which parenthesis matches which parenthesis.
(use-package rainbow-delimiters :defer t)
(dolist (hook '(js2-mode-hook js-mode-hook json-mode-hook emacs-lisp-mode-hook scheme-mode-hook))
(add-hook hook 'rainbow-delimiters-mode))
Anzu is amazing! It highlight the words that you wish to replace.
I have also bound the command to run the command via "Q" in vim normal-mode.
(use-package anzu
:config (global-anzu-mode 1)
:diminish (anzu-mode))
This will highlight words that are misspelled. Flyspell-prog-mode will do this for programming, flyspell-mode is for text files.
~/.config/emacs/images/flyspell.png
Also flyspell binds C-c $ to flyspell fix word before point. BUT I used to prefer that to be bound to endless/ispell-word-then-abbrev.
(add-hook 'prog-mode-hook (lambda ()
(flyspell-prog-mode)))
;;(unbind-key (kbd "C-c $") flyspell-mode-map)
;;(global-set-key (kbd "C-c $") #'endless/ispell-word-then-abbrev))
;; enable flyspell mode for all of my text modes. This will enable flyspell to underline misspelled words.
(add-hook 'text-mode-hook (lambda ()
(flyspell-mode)))
;;(unbind-key (kbd "C-c $") flyspell-mode-map)
;;(global-set-key (kbd "C-c $") #'endless/ispell-word-then-abbrev))
Oddly enough web-mode doesn't seem to support flyspell.
Projectile is a package that attempts to make it easier for Emacs to do various commands that are specific to your repositories.
(use-package projectile
:config
;;(use-package helm)
;;(use-package helm-projectile)
(setq projectile-enable-caching t
projectile-completion-system 'helm)
(helm-projectile-on)
:diminish (projectile-mode)
:hook (prog-mode . projectile-global-mode)
:bind-keymap
("C-c p" . projectile-command-map)
:defer t)
#+END_SRC
Projectile also supports setting projectile-project-compilation-dir via a [[info:emacs#Directory%20Variables][.dir-locals.el]] file. This file is a specific Emacs file that sets per-buffer variables for any files inside that directory. I use this for making the projectile-compile-project (C-c p c p) command to work in my ~/programming/c/ directory. You can view that [[file:~/programming/c/.dir-locals.el::((nil%20.%20((projectile-project-compilation-dir%20.%20"c/"))))][file]] here.
Alternatively, you could learn to use GNU autotools, specifically automake, which would probably make your life a little easier.
* auth-source
:ID: 90ce5dc0-d72b-4263-a0c6-14cc88a5838c
:END:
If I have a .authinfo, .authinfo.gpg, or .netrc, then load auth-source.el
How to use auth-source and gpg to encrypt files. Also how to transfer keys between machines.
https://www.masteringemacs.org/article/keeping-secrets-in-emacs-gnupg-auth-sources
Auth-source.el, lets you save your various logins and password for different servers in one file. For someone like me, who has never gotten ssh keys to work (it always ALWAYS ANNOYING prompts me for a password), I just have my information stored in .authinfo.gpg, which is an encrypted file.
Ensure that you have f.el
#+BEGIN_SRC emacs-lisp
(use-package f :defer t)
;;(require 'f)
According to Mastering Emacs blog...gpg is an outdated (ancient) version of gpg. gpg2 is newer and should be used!
gpg is the version more suited for servers. Gpg2 is the version more suited for desktop use. Here is a stackoverflow answer. describing the difference between gpg and gpg2.
At the moment I dual boot Parabola GNU/Linux and GuixSD. At some point, I want to migrate over to use GuixSD, but Parabola has some features, services, and packages that Guix lacks. So until that time, I'll have to use both. BUT the good news is that I can tell Emacs which gpg binary to use based upon my host name. If my host name is "antelope" the default GuixSD host-name then make the egp-gpg-program be gpg. If it's parabola, make it "gpg2". "parabola" uses gpg2. GuixSD needs to use gpg. gpg2 is the newer version. You should use gpg2 if you can.
(setq epg-gpg-program "gpg2")
gpg2
(when (and (display-graphic-p) (f-file? "~/.authinfo.gpg"))
;; only use the encrypted file.
(setq auth-sources '("~/.authinfo.gpg")))
Don't let Emacs use the default gpg agent pin. Instead make Emacs prompt you for a password.
I'm not sure what this is?
;;(setenv "GPG_AGENT_INFO" nil)
(defun my-recentf-startup ()
"My configuration for recentf."
(recentf-mode 1)
(setq recentf-max-saved-items 1000
recentf-exclude '("/tmp/"
"^.*autoloads.*$"
"^.*TAGS.*$"
"^.*COMMIT.*$"
"^.*pacnew.*$"
;; in case I ever want to exclude shh files, I can add this next line.
;; "/ssh:"
))
(add-to-list 'recentf-keep "^.*php$//")
(recentf-auto-cleanup)
;;every 5 minutes I should try to save the list of recent files.
;; if emacs quits abrubtly, then those files will be lost.
(run-at-time nil (* 5 60) 'recentf-save-list))
(add-hook 'after-init-hook 'my-recentf-startup)
(setq-default grep-highlight-matches t
grep-scroll-output t)
;; ag is the silver searcher. It lets you search for stuff crazy fast
(when (executable-find "ag")
(use-package ag :defer t)
(use-package helm-ag :defer t)
(use-package wgrep-ag :defer t )
(setq-default ag-highlight-search t))
(use-package yasnippet
;; (define-key company-mode-map (kbd "TAB") #'yas-expand)
;; (define-key company-mode-map (kbd "<tab>") #'yas-expand)
;; don't use yas-global-mode. I don't need yas in eww-mode
;;:hook (prog-mode text-mode)
:config
;; get some of the yasnippet snippets
(yas-global-mode)
;;(use-package yasnippet-snippets)
)
#+END_SRC
If I modify a buffer via a yasnippet with a back-ticks like ~`SOME ELISP CODE `~, then yasnippet will issue a warning. Let's tell yasnippet to ignore that.
#+BEGIN_SRC emacs-lisp
(with-eval-after-load 'warnings
(add-to-list 'warning-suppress-types '(yasnippet backquote-change)))
;; Assuming the Guix checkout is in ~/src/guix.
(with-eval-after-load 'yasnippet
(add-to-list 'yas-snippet-dirs "/home/joshua/prog/gnu/guix/guix-src/etc/snippets")
(add-to-list 'yas-snippet-dirs "/home/joshua/.config/emacs/auto-insert-directory"))
This advises yasnippet, so that when I expand a snippet, I change to insert state and leave in insert state.
But it is probably not necessary. When I am about to expand a snippet, I am typically in insert state anyway.
(when evil-mode
(advice-add 'evil-insert-state :before 'yas-expand)
(advice-add 'evil-insert-state :after 'yas-expand))
:PROPERTIES: :ID: 08c8e25c-6513-4ad5-a598-a1b40db2040b :END:
Geiser is already installed. I just want to make sure that Geiser gets info from the guix source files.
Getting the "perfect setup" setup.
(with-eval-after-load 'geiser-guile
(add-to-list 'geiser-guile-load-path "/home/joshua/prog/gnu/guix/guix-src"))
(load-file "/home/joshua/prog/gnu/guix/guix-src/etc/copyright.el")
To do auto updating of copyright.
(setq copyright-names-regexp
(format "%s <%s>" user-full-name user-mail-address))
(add-hook 'after-save-hook 'copyright-update)
I use avy mode for avy jump to char, which is a little nicer than ace-jump mode, but not by much.
#+BEGIN_SRC emacs-lisp (use-package avy :defer t :config (setq avybackground t avy-highlight-first t) ;; https://github.com/abo-abo/avy ;; What does that do? (setq avy-keys (number-sequence ?e ?t ))) #+END_SRC
Filling is what one does to insert actual or invisible newlines at a really long sentence to make a paragraph. For example:
This is a really long sentence, but when you call fill paragraph on it, with point inside it, it might look something like this:
This is a really long sentence, but when you call fill paragraph on it, with point inside it, it might look something like this:
Emacs by default does not automatically call fill paragraph for you. Instead, it shows your visual characters to show you that your text is too big for the buffer. It looks like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi bibendum elit sodales ↵
sapien porta, ut aliquet orci volutpat. Nulla non est vel ante pulvinar elementum eu ac ↵
neque. Aliquam dapibus ipsum vulputate varius faucibus. Proin finibus rhoncus diam in ↵
interdum. Nullam a elit auctor felis eleifend rutrum. Fusce odio quam, vehicula vitae ↵
ullamcorper sit amet, consectetur ac elit. Nunc at rutrum risus, quis ullamcorper risus. ↵
Global visual line mode, will automatically remove those arrows and make it looks like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi bibendum elit sodales
sapien porta, ut aliquet orci volutpat. Nulla non est vel ante pulvinar elementum eu ac
neque. Aliquam dapibus ipsum vulputate varius faucibus. Proin finibus rhoncus diam in
interdum. Nullam a elit auctor felis eleifend rutrum. Fusce odio quam, vehicula vitae
ullamcorper sit amet, consectetur ac elit. Nunc at rutrum risus, quis ullamcorper risus.
(add-hook 'after-init-hook 'global-visual-line-mode)
(global-set-key (kbd "C-c q") #'fill-paragraph)
Aggressive indent attempts to aggressively indent you code after you change various aspects of it. It doesn't work well with org-mode and web-mode. And it seems to aggressively re-indent my entire scheme buffers.
(use-package aggressive-indent
:defer t
:config
(add-to-list 'aggressive-indent-excluded-modes 'makefile-gmake-mode)
(add-to-list 'aggressive-indent-excluded-modes 'makefile-mode)
(add-to-list 'aggressive-indent-excluded-modes 'web-mode)
(add-to-list 'aggressive-indent-excluded-modes 'org-mode)
(add-to-list 'aggressive-indent-excluded-modes 'clojure-mode-hook)
(add-to-list 'aggressive-indent-excluded-modes 'emacs-lisp-mode-hook)
(add-to-list 'aggressive-indent-excluded-modes 'common-lisp-mode-hook)
(add-to-list 'aggressive-indent-excluded-modes 'scheme-mode-hook)
(add-to-list 'aggressive-indent-excluded-modes 'lisp-mode-hook)
;; :hook (message-mode . aggressive-indent-mode)
)
This mode turns on proper indentation for scheme code for use by Guix System.
(add-hook 'scheme-mode-hook 'guix-devel-mode)
:PROPERTIES: :ID: d98de97e-3e06-4abe-86f9-4baed8d5d9cf :END:
(use-package aggressive-fill-paragraph
:config
(afp-setup-recommended-hooks)
(add-hook 'mail-mode-hook #'aggressive-fill-paragraph-mode)
(add-hook 'message-mode-hook #'aggressive-fill-paragraph-mode)
;;(add-hook 'scheme-mode-hook #'aggressive-fill-paragraph-mode)
;;(add-hook 'org-mode-hook #'aggressive-fill-paragraph-mode)
;;(add-to-list 'afp-fill-comments-only-mode-list 'scheme-mode)
)
(use-package json-mode
:mode
("\\.json\\'" . json-mode))
First, Emacs doesn't handle less well, so use cat instead for the shell pager:
;;(setenv "PAGER" "cat")
using ac-source-filename IS super useful it is only activated if you start to type a file like "./", "../", or "~/" but then it's awesome!
(add-hook 'eshell-mode-hook '(lambda ()
(setq shell-aliases-file "~/.config/emacs/alias")))
TODO make this lazy loading
(when (and (executable-find "fish")
(require 'fish-completion nil t))
(progn
(add-hook 'eshell-mode-hook 'fish-completion-mode)))
(defun my/set-fill-column-80 ()
"set the fill column to 80"
(interactive)
(auto-fill-mode)
(setq fill-column 80)
(set-fill-column 80))
(use-package markdown-mode
:defer t
:commands (markdown-mode gfm-mode)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.mdwn\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:init (setq markdown-command "multimarkdown"))
;; writing GNU/Hurd wiki edits should only have 80 characters
;; per column
(add-hook 'markdown-mode-hook 'my/set-fill-column-80)
:PROPERTIES: :ID: 55ba0f1d-1032-412c-a974-2a2c81990858 :END: Open .defs files in c-mode. These are found in the Hurd source code.
(add-to-list 'auto-mode-alist '("\\.defs?\\'" . c-mode))
This mode lets you read epub documents inside Emacs. How cool is that?
(use-package nov
:mode ("\\.epub\\'" . nov-mode))
(use-package nginx-mode :defer t)
(add-to-list 'auto-mode-alist '("/nginx/sites-\\(?:available\\|enabled\\)/" . nginx-mode))
(use-package lua-mode
:mode ("\\.lua\\'" . lua-mode))
Apparently you can use this to set make magit-status open in a full frame.
(use-package magit :defer t
:init
(setq magit-display-buffer-function 'magit-display-buffer-fullframe-status-v1)
:config
(setq magit-display-buffer-function 'magit-display-buffer-fullframe-status-v1))
In ediff mode, open up org-files in showall. That way you don't have to tab open things.
(add-hook 'ediff-prepare-buffer-hook #'outline-show-all)
When we start working on git-backed files, use git-wip if available. This auto saves git files in a wip in progress branch on the current progress. You can learn more here: https://magit.vc/manual/2.1/magit/Wip-Modes.html
(after-load 'magit
;;(global-magit-wip-save-mode)
(setq magit-display-buffer-functions 'magit-display-buffer-fullframe-status-v1))
(setq-default
magit-save-some-buffers nil
magit-diff-refine-hunk t)
If a command takes longer than 5 seconds, pop up the process buffer.
(setq magit-process-popup-time 15)
I also don't really need scroll-bar-mode enabled with ediff, but I can't get scroll-bar-mode to turn back on.
(defun my/turn-off-scroll-bars ()
"My specific function for turning off my vertical scroll-bars."
(set-scroll-bar-mode nil))
(defun my/turn-off-scroll-bars ()
"My specific function for turning on on scoll-bars."
(set-scroll-bar-mode t))
TODO I can probably remove one or two of these hooks.
(add-hook 'ediff-load-hook 'my/turn-off-scroll-bars)
(add-hook 'ediff-mode-hook 'my/turn-off-scroll-bars)
(add-hook 'ediff-suspend-hook 'my/turn-on-scroll-bars)
(add-hook 'ediff-quit-hook 'my/turn-on-scroll-bars)
Major mode for editing gitignore files
(use-package gitignore-mode :defer t )
(use-package gitconfig-mode :defer t )
Though see also vc-annotate's "n" & "p" bindings this package is soooo cool! you execute git-timemachine, you can then press p and n to go to the previous and next verions. w copies the git hash of the current buffer, and q quits the buffer
(use-package git-timemachine :defer t)
:PROPERTIES: :ID: 372e6c67-514b-4e1e-8d25-9be2a30da22f :END: Type this command on any line of a repo. It'll tell you the commit when it appeared.
(use-package git-messenger :defer t )
(global-set-key (kbd "C-x v p") #'git-messenger:popup-message)
;; since I'm using helm-mode, magit will use helm-completion for stuff! awesome! This shows you in the fringes of the buffer (this is the left column on the left side of your buffer) whick text in a buffer has not yet been committed.
~/.config/emacs/images/vc-diff.png
#+BEGIN_SRC emacs-lisp (use-package diff-hl :defer t) (add-hook 'prog-mode-hook 'turn-on-diff-hl-mode) (add-hook 'vc-dir-mode-hook 'turn-on-diff-hl-mode) #+END_SRC :PROPERTIES: :ID: 425e59a0-c254-44df-b50b-d008d5258df8 :END:
Dired is the Emacs file manager. It looks like this:
~/.config/emacs/images/dired.png
It lets you rename files, run massive search and replace commands, compress files, etc.
Enable async dired commands.
And also, do not open multiple dired buffers, as I traverse a directory tree.
(after-load 'dired
;;(autoload 'dired-async-mode "dired-async.el" nil t)
(put 'dired-find-file-other-buffer 'disabled t)
;;(dired-async-mode 1)
)
alter net
http://whattheemacsd.com/setup-dired.el-01.html I don't need dired to automatically show me all the details ie: all the permissions and stuff If I do want the details I can use ")" to show them and "(" to hide them again
(use-package dired-details
:config
(setq-default dired-details-hidden-string "--- ")
:defer t
)
(use-package dired
;; before loading dired, set these variables
:init
(load "dired-x") ;; for dired-omit-mode
(setq-default diredp-hide-details-initially-flag nil
dired-dwim-target t
;;omit boring auto save files in dired views
dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$")
;;:config ;; after loading dired, do this stuff
;;(load "dired-x")
;;(setq wdired-allow-to-change-permissions t)
:bind
(:map dired-mode-map
("/" . helm-swoop)
([mouse2] . dired-find-file)
("e" . 'ora-ediff-files)
))
(with-eval-after-load 'dired
(add-hook 'dired-mode-hook 'dired-omit-mode)
;; this doesn't seem to work :
(add-hook 'dired-mode-hook 'all-the-icons-dired-mode))
(defun ora-ediff-files ()
(interactive)
(let ((files (dired-get-marked-files))
(wnd (current-window-configuration)))
(if (<= (length files) 2)
(let ((file1 (car files))
(file2 (if (cdr files)
(cadr files)
(read-file-name
"file: "
(dired-dwim-target-directory)))))
(if (file-newer-than-file-p file1 file2)
(ediff-files file2 file1)
(ediff-files file1 file2))
(add-hook 'ediff-after-quit-hook-internal
(lambda ()
(setq ediff-after-quit-hook-internal nil)
(set-window-configuration wnd))))
(error "no more than 2 files should be marked"))))
https://www.topbug.net/dired-icon/
(use-package dired-icon )
(add-hook 'dired-mode-hook 'dired-icon-mode)
But it doesn't seem to work ??? I found this code snippet here: https://truongtx.me/2013/04/02/emacs-async-file-copying-in-dired-using-rsync
(defun tmtxt/dired-rsync (dest)
(interactive
;; offer dwim target as the suggestion
(list (expand-file-name (read-file-name "Rsync to:" (dired-dwim-target-directory)))))
;; store all selected files into "files" list
(let ((files (dired-get-marked-files nil current-prefix-arg)))
;; the rsync command
(setq tmtxt/rsync-command "rsync -arvz --progress ")
;; add all selected file names as arguments to the rsync command
(dolist (file files)
(setq tmtxt/rsync-command
(concat tmtxt/rsync-command
(shell-quote-argument file)
" ")))
;; append the destination
(setq tmtxt/rsync-command
(concat tmtxt/rsync-command
(shell-quote-argument dest)))
;; run the async shell command
(async-shell-command tmtxt/rsync-command "*rsync*")
;; finally, switch to that window
(other-window 1)))
;;; bind it to C-c C-r
(define-key dired-mode-map (kbd "C-c C-r") 'tmtxt/dired-rsync)
press "S" in a dired buffer to see dired sort in action
;;(use-package dired-sort )
;;(use-package dired+ :defer t)
Colourise CSS colour literals
~/.config/emacs/images/css-colorize.png
(use-package rainbow-mode :defer t)
(dolist (hook '(css-mode-hook html-mode-hook sass-mode-hook))
(add-hook hook 'rainbow-mode))
(use-package sass-mode :defer t)
(use-package scss-mode :defer t
:config
(setq-default scss-compile-at-save t)
(setq scss-sass-command "/home/joshua/.guix-profile/bin/sassc"))
t
Create a after save command to compile scss files:
(defun my/sassc-minify-function ()
"Minifying sassc files."
(interactive)
(when (eq major-mode 'scss-mode)
;; compile scss into css
(progn
(async-shell-command
(concat "sassc " (buffer-file-name) " "
(s-replace ".scss" ".css" buffer-file-name)) "*sassc compilation buffer*")
;; minimize the css into .min.css
(async-shell-command
(concat "sassc -t compressed " (buffer-file-name) " "
(s-replace ".scss" ".min.css" buffer-file-name))
"*sassc compression compilation buffer*"))))
(add-hook 'scss-mode-hook '(lambda ()
(add-hook 'after-save-hook 'my/sassc-minify-function nil t)))
(add-to-list 'display-buffer-alist (cons "\\\*sassc compilation buffer\\\*" (cons #'display-buffer-no-window nil)))
(add-to-list 'display-buffer-alist (cons "\\\*sassc compression compilation buffer\\\*" (cons #'display-buffer-no-window nil)))
(use-package less-css-mode )
;; I don't think I've ever used skewer-mode.
;; (when (featurep 'js2-mode)
;; (use-package skewer-less))
:PROPERTIES: :ID: 2586b70f-d7c5-475a-bb56-2236aa453dae :END:
(use-package css-eldoc :defer t)
;;(autoload 'turn-on-css-eldoc "css-eldoc")
(add-hook 'css-mode-hook 'css-eldoc-enable)
:PROPERTIES: :ID: 2c0894d7-393a-45f2-a84c-c56acb03f837 :END: You should read more about css abbreviations with emmet mode! https://github.com/smihica/emmet-mode#css-abbreviations
(add-hook 'css-mode-hook 'emmet-mode) ;; enable Emmet's css abbreviation.
I can use XMPP (previously knows as jabber) inside emacs!!! Awesome!!!
(use-package jabber
:defer t
:config
(defalias 'my-jabber-connect-all 'jabber-connect-all)
;;(use-package helm)
:init
(setq jabber-account-list '(("jbranso@dismail.de"))
jabber-history-enabled t
jabber-history-muc-enabled t))
(when my-onlinep
(progn
(add-hook 'emacs-startup-hook 'jabber-connect-all)
;; enable spell checking for jabber.
(add-hook 'jabber-chat-mode-hook 'flyspell-mode)))
Connecting to Jabber ==============
Now, type 'C-x C-j C-c' and enter your JID and password. If you successfully connect, jabber.el will download your roster and display it in a buffer called '*-jabber-roster-*'.
The default command to read the next unread jabber message is really silly. Let's change that.
(global-set-key (kbd "C-x C-j u") 'jabber-activity-switch-to)
(global-set-key (kbd "C-x C-j C-u") 'jabber-activity-switch-to)
(use-package ledger-mode
:mode
("\\.ledger?\\'" . ledger-mode))
:PROPERTIES: :ID: d5149a56-9461-46f6-909b-cbacc0ef5b52 :END:
Automatically fill in the paragraph that you are typing.
#+BEGIN_SRC emacs-lisp (add-hook 'message-mode-hook 'auto-fill-mode) (add-hook 'mail-mode-hook 'auto-fill-mode) #+END_SRC Emacs minor mode to hide or display structured section of code. VERY COOL!
Try to get hs-minor-mode to work with JSON, because that would be super cool!
(use-package hideshow
:bind (("C-x C-h" . hs-toggle-hiding)
("C-x C-S-+" . hs-show-all))
:init
(add-hook #'json-mode-hook #'hs-minor-mode)
(add-hook 'c-mode-hook 'hs-minor-mode)
:config
(setq hs-special-modes-alist
(mapcar 'purecopy
'((c-mode "{" "}" "/[*/]" nil nil)
(c++-mode "{" "}" "/[*/]" nil nil)
(java-mode "{" "}" "/[*/]" nil nil)
(js-mode "{" "}" "/[*/]" nil)
(json-mode "{" "}" "/[*/]" nil)
(javascript-mode "{" "}" "/[*/]" nil)))))
Company mode has bound tab to complete the common part between two snippets. I'd rather have tab mean select the first snippet. I'm getting some of the code from this gist: https://gist.github.com/nonsequitur/265010
(use-package company
:defer t
:config
(setq company-idle-delay .2)
(define-key company-active-map "\C-n" #'company-select-next)
(define-key company-active-map "\C-p" #'company-select-previous)
(define-key company-active-map (kbd "<tab>") #'company-complete-selection)
:diminish (company-mode))
(add-hook 'prog-mode-hook 'global-company-mode)
#+END_SRC
** show yasnippets in company mode
:ID: f9dba9a6-e011-48cb-8a14-6a365fe78c1c
:END:
#+BEGIN_SRC emacs-lisp
(dolist (hook '(prog-mode-hook
text-mode-hook
org-mode-hook))
(add-hook hook
(lambda ()
(set (make-local-variable 'company-backends)
'((company-dabbrev-code company-yasnippet))))))
This is not necessary, because spaceline theme provides this functionality.
Show cute flycheck error-images in the modeline.
(use-package flycheck-status-emoji :defer t)
; :config (set-fontset-font t nil "Symbola")
Color the mode line based on how the errors flycheck finds or doesn't find
(use-package flycheck-color-mode-line :defer t)
Show all errors in a popup.
(use-package flycheck
:config
;;(flycheck-pos-tip-mode)
;; enable flychek for programming modes
:defer t)
#+END_SRC
Enable flycheck for all programming modes.
#+BEGIN_SRC emacs-lisp
(add-hook 'prog-mode-hook 'flycheck-mode)
#+END_SRC
* helm
:ID: a077141f-fed4-4e16-92fb-5c31ae849737
:END:
By default helm-do-git-grep, searching the current directory. C-u helm-do-git-grep searches the entire project.
Helm mode is an incremental completion framework, that is much better than ido-mode.
[[~/.config/emacs/images/helm-buffers-list.gif]]
Before we load any helm things, need to load helm-flx so it uses flx instead of helm's fuzzy matching.
We can autoload helm functionality with the bind-keymap.
Here is the maintainer's helm configuration file:
https://github.com/thierryvolpiatto/emacs-tv-config/blob/master/init-helm.el
More info about helm:
https://emacs-helm.github.io/helm/#getting-started
#+BEGIN_SRC emacs-lisp
(use-package helm
:bind-keymap
("C-c h" . helm-command-map)
:config
;; emacs 27 and helm-mode have a memory leak. The below line
;; fixes the memory leak.
(setq helm-ff-keep-cached-candidates nil)
(require 'helm-config)
(helm-mode 1)
(defalias 'helm-browse-kill-ring 'helm-show-kill-ring)
(use-package helm-swoop)
(use-package helm-flx
;; TODO what is this?
:config (helm-flx-mode +1))
:bind
(("M-x" . helm-M-x)
("C-x C-f" . helm-find-files)
:map helm-find-files-map
("C-h" . helm-select-action)
("TAB" . helm-execute-persistent-action)))
According to the github repo this next line is all that I need to install helm
(defun my/config-helm-function ()
"This just sets up helm."
(interactive)
;;(define-key helm-find-files-map (kbd "<tab>") 'helm-ff-RET)
;;(define-key helm-map (kbd "<backtab>") 'helm-select-action)
;;(global-set-key (kbd "C-c h s") 'helm-do-ag)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-set-key (kbd "C-x r b") 'helm-bookmarks))
(add-hook 'after-init-hook 'my/config-helm-function)
I've installed helm-ag, which might be cool.
(setq
;;don't let helm swoop guess what you want to search... It is normally wrong and annoying.
helm-swoop-pre-input-function #'(lambda () (interactive))
;; tell helm to use recentf-list to look for files instead of file-name-history
helm-ff-file-name-history-use-recentf t
;; let helm show 2000 files in helm-find-files
;; since I let recent f store 2000 files
helm-ff-history-max-length 2000
;; I've set helm's prefix key in init-editing utils
;; don't let helm index weird output files from converting .tex files to pdf for example
helm-ff-skip-boring-files t
;; enable fuzzy mating in M-x
helm-M-x-fuzzy-match t
helm-recentf-fuzzy-match t
helm-apropos-fuzzy-match t
;;the more of these sources that I have, the slower helm will be
helm-for-files-preferred-list '(
helm-source-buffers-list
helm-source-recentf
helm-source-bookmarks
helm-source-file-cache
helm-source-files-in-current-dir
;;helm-source-locate
;;helm-source-projectile-files-in-all-projects-list
;;helm-source-findutils
;;helm-source-files-in-all-dired
))
Helm system packages is a front-end to install packages with pacman!
https://github.com/emacs-helm/helm-system-packages
(use-package helm-system-packages :defer t)
I suppose the only thing that I really want to tweak about shr mode is to set it to have body {padding-left:20px;} righ!? lol acdw: That would be pretty sweet! i have a little reading mode in my config that enables olivetti mode, which kind of does that olivetti mode...I'll look that up [15:14] https://tildegit.org/acdw/emacs/src/branch/main/lisp/acdw.el#L518 is my thing acdw: thanks! I might really like that for org-mode too! maybe... [15:15] there's olivetti and writeroom, similar but different
Space line is not allowing my jabber notifications to come through...
(use-package spaceline)
(use-package spaceline-all-the-icons
:config
(setq spaceline-highlight-face-func 'spaceline-highlight-face-evil-state)
(spaceline-all-the-icons-theme))
Adding a custom spaceline-all-the-icons segment:
(spaceline-all-the-icons-theme 'my/jabber "Hello" 'etc)
Ok how do I turn off this new custom segment?
(spaceline-all-the-icons--turn-off 'my/jabber)
Make the mode line look prettier. I'd like to use spaceline eventually, but oh well.
Smart mode line is causing some issues with tramp and loading buffers.
The function that is causing the trouble is:
sml/*if-necessary
(use-package smart-mode-line-powerline-theme :defer t)
Smart mode line apparently is more active and works w/ just about anything
(use-package smart-mode-line
:init
(setq sml/theme 'powerline ;; or automatic
;; automatic will try to automatically configure things
;; emacs keeps prompting me to run the smart-mode-line-theme. This is a word around that I found on github
sml/no-confirm-load-theme t
powerline-arrow-shape 'curve
powerline-default-separator-dir '(right . left)
sml/mode-width 0
;; this makes sure that the mode line doesn't go off the screen
sml/name-width 40
rm-whitelist nil
rm-blacklist '(" Helm" " Fly" " Wrap" " Abbrev" " Ind"))
(sml/setup))
/ssh:joshua@richardrahl:/etc/nginx/sites-available/laundrysucks.io is a long file name. Let's change that:
(add-to-list 'sml/replacer-regexp-list '("^/ssh:joshua@richardrahl:/etc/nginx/" ":rahl/nginx:") t)
Customizing the smart-mode-line theme! I can customize sml. I just need to tweak the variable sml/theme, and then call sml/setup.
(custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(default ((t (:foreground "#DCDCCC" :background "#3F3F3F")))) '(sml/charging ((((class color) (min-colors 89)) (:foreground "#BFEBBF")))) '(sml/client ((t (:inherit sml/prefix :background "black")))) '(sml/filename ((t (:inherit sml/global :background "#383838" :foreground "#6ca0a3" :weight bold)))) '(sml/folder ((t (:inherit sml/global :background "#383838" :foreground "Black" :weight normal)))) '(sml/global ((t (:background "black" :foreground "#6f8f6f" :inverse-video nil :weight bold)))) '(sml/minor-modes ((t (:inherit sml/folder :foreground "#8fb28f" :weight ultra-bold)))) '(sml/modes ((t (:inherit sml/global :background "#6f8f6f" :foreground "#2b2b2b" :weight bold)))) '(sml/name-filling ((t (:inherit sml/prefix :background "#6f8f6f" :weight normal)))) '(sml/position-percentage ((t (:inherit sml/prefix :background "#6f8f6f" :foreground "#2b2b2b" :weight normal)))) '(sml/prefix ((t (:inherit sml/global :background "grey17" :foreground "#8fb28f")))) '(sml/process ((t (:inherit sml/prefix :background "#6f8f6f" :weight bold)))))
#+BEGIN_SRC emacs-lisp ;; (require 'init-sunrise) #+END_SRC
(use-package ivy :config (setq ivy-height 30))
(use-package counsel )
(reqgister)
;; Ieed to use (set-register register value)
" regist is this: Alisments (NAME . CONTENTS), one for each Emacs register. NAMEaracter (a number). CONTENTS is a string, number, marker, list or areturned by `registerv-make'.
So m to register command must transform my NAME char into an ASCII number. fun. "
(defmber-to-register (number register) (ive "n number: \nMregister: ") ;;to-register number register) ;;r to use (ster register number))
;; g is getting soo annoying and it's not working at all ;;(pister-alist)
(defsert-register (register) (ive "Mregister: ") (pister) (igister register))
(defcrement-register ()) (get-register "r")
(defdra-register (:color pink :hint nil) " ^Sto ^Insert^ ^Increase^ ^^^^---------------------------------------------------------------- _n_uregister _i_nsert number register _I_ncrease the register C-u C-x r n R insebers left C-x r i R C-u number C-x r + r ofle Insert _t_ext to register C- C-x r s R " ;; ("mber-to-register :exit t) ("ngle-number-lines :exit t)
;; ("sert-register :exit t) ; Show (expand) everything ("to-register :exit t) ; Show (expand) everything
;;e ("crement-register :exit t) ; Hide everything but the top-level headings
("leave"))
;; I set this hydra to a keybinding. So I don't have to remember all of the keybindings (glokey (kbd "C-c C-r") 'hydra-register/body) ;; aother modes try to set C-c C-r to a keybinding. I am overriding them. (witfter-load 'org (dy org-mode-map (kbd "C-c C-r") 'hydra-register/body)) (witfter-load 'web-mode (dy web-mode-map (kbd "C-c C-r") 'hydra-register/body)) (witfter-load 'php-mode (dy php-mode-map (kbd "C-c C-r") 'hydra-register/body)) http://emacsist.com/10425
;;(use-package rust )
My hacky Emacs autocorrect functionality, is not the best. It changes things that I don't want changed all the time, etc.
Until it's better, I don't want to use it
;; (org-babel-load-file "/home/joshua/programming/emacs/autocorrect/autocorrect.org" )
Add abbrev-mode to text modes and program modes to turn on autocorrect like functionality.
(dolist (hook '(org-mode-hook
prog-mode-hook
text-mode-hook))
(add-hook hook (lambda ()
(abbrev-mode 1)
(diminish 'abbrev-mode))))
this will be cool to monitor my commands. But I have to initialize it...It will not record commands by default. I don't really use this functionality. I never see what commands I'm using. So I'll ignore it for now. (use-package mwe-log-commands) (me:log-keyboard-commands)
(require 'init-python-mode)
(require 'init-gitgub)
http://alexott.net/en/writings/emacs-vcs/EmacsDarcs.html (require 'init-darcs) I also hardly ever use this sx package, which is an amazing package! searching stack exchange via emacs! C-c S (use-package sx ) This is probably how I can embed yasnippets into various modes
(require 'init-dubcaps)
reduce the frequency of garbage collection by making it happen on each 50MB of allocated data (the default is on every 0.76MB) this might help improve performance ;;(setq gc-cons-threshold 50000000)
(require 'bookmark) (defhydra hydra-bookmark (:color pink :hint nil) " ^Edit^ ^Jump^ ^Set^ ^^^^^^------------------------------------------------------ _e_: edit bookmarks _j_ump to bookmark _s_: set bookmark _r_: rename _J_ump to gnus bookmark _S_: set a gnus bookmark " ;; Edit ("e" edit-bookmarks :exit t) ; Up ("r" helm-bookmark-rename :exit t) ; Up
;; Jump ("j" bookmark-jump :exit t) ; Show (expand) everything ("J" gnus-bookmark-jump :exit t) ; Show (expand) everything
;; Set ("s" bookmark-set :exit t) ; Hide everything but the top-level headings ("S" gnus-bookmark-set :exit t) ; Hide everything but the top-level headings
("z" nil "leave"))
;; I want to set this hydra to a keybinding. So I don't have to remember all of the keybindings (global-set-key (kbd "C-c C-b") 'hydra-bookmark/body) ;; a ton of other modes try to set C-c C-b to a keybinding. I am overriding them. (with-eval-after-load 'org (define-key org-mode-map (kbd "C-c C-b") 'hydra-bookmark/body)) (with-eval-after-load 'web-mode (define-key web-mode-map (kbd "C-c C-b") 'hydra-bookmark/body)) (with-eval-after-load 'php-mode (define-key php-mode-map (kbd "C-c C-b") 'hydra-bookmark/body))
Show eldoc popups in pos-tips. I got the idea here. (defun my-eldoc-display-message (format-string &rest args) "Display eldoc message near point." (when format-string (pos-tip-show (apply 'format format-string args)))) (setq eldoc-message-function #'my-eldoc-display-message) This turn ^L into nice long lines.
This package turns "^L" into a delimiting line character. It is easy to insert such a character. Just put point over a char, press "r" in normal mode (replace), then press C-l. That command replaces the character with "^L".
To see what this looks like, then open the snippet below with "C-c '".
(use-package page-break-lines
:diminish page-break-lines-mode
:config (add-hook 'prog-mode-hook 'page-break-lines-mode))
DO NOT enable page break lines mode with org-mode. Org-mode freaks out when it sees "^L"! Org-mode will turn "^L" into 50+ lines. It looks really wrong.
Wtrin is a small emacs package that gets you the local weather forcast. It pulls from http://wttr.in/.
~/.config/emacs/images/weather.png
(use-package wttrin
:commands (wttrin)
:init
(setq wttrin-default-cities
'("West Lafayette"))
(setq wttrin-default-accept-language '("Accept-Language" . "en-US")))
(defun weather ()
"Show the local weather via wttrin"
(interactive)
(wttrin))
This package is like guide-key, but better. As you start to type a keychord, but then forget how to finish it, which-key will bring up a small buffer to show you possible completions.
~/.config/emacs/images/which-key.png
(use-package which-key
:config
;; max height of which-key frame: number of lines (an integer)
(setq which-key-frame-max-height 60)
(which-key-mode 1))
Make "-->" look like --> and ">" look >
cool utf-8 characters.
Add some more characters cool characters. You can get some cool ideas from prettymode The characters end up looking like:
~/.config/emacs/images/pretty-mode.png
(defun my/add-extra-prettify-symbols ()
(global-prettify-symbols-mode 1)
(mapc (lambda (pair) (push pair prettify-symbols-alist))
'(
(">=" . ?≥)
("<=" . ?≤)
("\\geq" . ?≥)
("\\leq" . ?≤)
("\\neg" . ?¬)
("\\rightarrow" . ?→)
("\\leftarrow" . ?←)
("\\infty" . ?∞)
("-->" . ?→)
("<--" . ?←)
("\\exists" . ?∃)
("\\nexists" . ?∄)
("\\forall" . ?∀)
("\\or" . ?∨)
("\\and" . ?∧)
(":)" . ?☺)
("):" . ?☹)
(":D" . ?☺)
("\\checkmark" . ?✓)
("\\check" . ?✓)
("1/4" . ?¼)
("1/2" . ?½)
("3/4" . ?¾)
("1/7" . ?⅐)
;; ⅕ ⅖ ⅗ ⅘ ⅙ ⅚ ⅛ ⅜ ⅝ ⅞
("ae" . ?æ)
("^_^" . ?☻)
("function" .?ϝ)
)))
(add-hook 'after-init-hook 'my/add-extra-prettify-symbols)
;;(add-hook 'prog-mode-hook 'my/add-extra-prettify-symbols)
You can learn more about all the icons here.
~/.config/emacs/images/all-the-icons.png
You need the icons for this to work dummy.
(use-package all-the-icons :defer t)
(use-package all-the-icons-dired :defer)
(require 'mu4e)
;;(use-package mu4e-alert :defer t)
Tell mu where various folders are:
(setq
mu4e-maildir "~/.mail/dismail.de" ;; top-level Maildir
mu4e-sent-folder "/Sent" ;; folder for sent messages
mu4e-drafts-folder "/Drafts" ;; unfinished messages
mu4e-trash-folder "/Trash" ;; trashed messages
mu4e-refile-folder "/Archive") ;; saved messages
;; attempt to show images when viewing messages
(setq mu4e-view-show-images t)
(setq mu4e-get-mail-command nil
mu4e-update-interval 301)
If I want to look at Emacs bugs, I debbugs is useful for this.
#+BEGIN_SRC emacs-lisp (use-package debbugs :defer t) #+END_SRC
Slides inside Emacs
(use-package zpresent :defer t)
Create an org-file and M-x zpresent turns the file into a presentation. "n" is for next slide and "p" is for previous slide.
,* First Slide
Opening paragraph
,** Sub title 1
Some more information on the first slide
,** sub title 2
,* Second Slide
Opening paragraph
,** sub title 1
More info
,** sub title 2
Lots more info.
(use-package better-shell :defer t)
better-shell-remote-open
This command is actually quite cool: Try out better-shell-remote-open RET USERNAME@HOST RET PASSWORD RET
Pdf tools is a better pdf viewer than the default DocView.
(use-package pdf-tools
:mode ("\\.pdf\\'" . pdf-view-mode)
)
;;(pdf-tools-install)
:PROPERTIES: :ID: a5a5f993-e0a8-48c5-b80f-ccab9781591e :END:
With point in the or beginning middle of the line comment out the whole line with point at the end of the line, add a comment to the left of the line with a region marked, marked the region for delition with "C-u C-c" delete the marked regions and lines with "C-u C-u C-c" #+BEGIN_SRC emacs-lisp (use-package smart-comment
:bind ("C-c ;" . smart-comment) :config (with-eval-after-load 'org (local-unset-key "C-c ;"))) #+END_SRC This is a program that lets suggests valid elisp functions to use. It is SO cool!
~/.config/emacs/images/suggest.png
You can read more here.
(use-package suggest :defer t)
(use-package eglot :defer t)
#+BEGIN_SRC emacs-lisp (use-package emms :defer t :config (require 'emms-setup) (emms-all) (emms-default-players) (setq emms-source-file-default-directory "~/music/Ed Sheeran - +/")) #+END_SRC https://github.com/pashky/restclient.el
I can get GETs and POSTs from websites now! Very cool!
(use-package restclient
:mode (("\\.http\\'" . restclient-mode)))
Emacs dashboard displays a nice greating when you start the Emacs dashboard.
(use-package dashboard
:config
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
;;(add-to-list 'dashboard-items '(agenda) t)
(setq dashboard-items '((agenda . 5)
(recents . 5)
(projects . 5)))
(setq show-week-agenda-p t)
(dashboard-setup-startup-hook))
(use-package elscreen
:config
;(setq elscreen-prefix-key [26])
;;(setq elscreen-prefix-key "C-c z")
:bind (;;([<C-tab>] . elscreen-next)
((kbd "[<C-tab>]" . elscreen-next)))
(elscreen-start))
I need to use the other new package https://github.com/roman/golden-ratio.el
(use-package golden-ratio
:defer t
;;let's not use golden ratio on various modes
:config (setq golden-ratio-exclude-modes
'( "sr-mode" "ediff-mode" "ediff-meta-mode" "ediff-set-merge-mode" "gnus-summary-mode"
"magit-status-mode" "magit-popup-mode" "org-export-stack-mode"))
(golden-ratio-mode)
:diminish golden-ratio-mode)
(add-hook 'prog-mode-hook 'golden-ratio-mode)
#+END_SRC
I had to find the source code for turning off golden-ratio-mode. Because
~(golden-ratio-mode nil)~ does not turn off golden-ratio-mode.
#+BEGIN_SRC emacs-lisp
(defun my-ediff-turn-off-golden-ratio ()
"This function turns off golden ratio mode, when I
enter ediff."
(interactive)
(remove-hook 'window-configuration-change-hook 'golden-ratio)
(remove-hook 'post-command-hook 'golden-ratio--post-command-hook)
(remove-hook 'mouse-leave-buffer-hook 'golden-ratio--mouse-leave-buffer-hook)
;; I'm not sure what these functions did, but I guess golden ratio doesn't need them anymore?
;;(ad-deactivate 'other-window)
;;(ad-deactivate 'pop-to-buffer)
)
Let's turn off golden-ratio-mode when I am using ediff, and turn it back on when I quit ediff.
(add-hook 'ediff-mode-hook #'my-ediff-turn-off-golden-ratio)
(add-hook 'ediff-quit-merge-hook #'golden-ratio)
display line numbers in the fringe on the left of the page.
I'd love to globally enable linum mode, but it slows Emacs to a crawl on large org buffers. #+BEGIN_SRC emacs-lisp (dolist (hook '( c-mode-hook js2-mode-hook scss-mode-hook css-mode-hook php-mode-hook web-mode-hook emacs-lisp-mode-hook )) (progn (add-hook hook 'linum-mode) ))
#+END_SRC
I'd prefer to use nlinum mode, because it's faster. BUT it also makes it that I cannot open a new Emacs frame.
;; (use-package nlinum )
Should I get rip of this? Does my new modeline get rid of it?
Nicer naming of buffers for files with identical names. Instead of Makefile<1> and Makefile<2>, it will be Makefile | tmp Makefile | lisp this file is part of gnus emacs. I don't need to use use-package #+BEGIN_SRC emacs-lisp :toggle no (require 'uniquify) (setq uniquify-buffer-name-style 'reverse) (setq uniquify-separator " • ") (setq uniquify-after-kill-buffer-p t) (setq uniquify-ignore-buffers-re "^\\*") #+END_SRC Paradox adds some nice features to emacs install packages this sets up paradox to use my private token to access public repos. #+BEGIN_SRC emacs-lisp ;;(require 'init-paradox) #+END_SRC
This is a port of BBDB to EIEIO, which is emacs lisp's OO library. It has a nice manual, and maybe someday I'll use it.
(use-package ebdb :defer t
:config
(use-package company-ebdb ))
(provide 'init-load-small-packages)