Skip to content

Instantly share code, notes, and snippets.

View howardabrams's full-sized avatar

Howard Abrams howardabrams

View GitHub Profile
@howardabrams
howardabrams / .profile.sh
Last active December 31, 2019 03:31
Bulk of my server-side profile that when I first log into the system, it starts up Emacs as a daemon and a `tmux` session. From then on, I just attach to that `tmux,` and use `emacsclient` to edit files... especially with a `split-window`.
alias e='emacsclient -q -a emacs'
EDITOR=emacsclient
function e {
tmux new-window -a -n "emacs" "$EDITOR $@"
}
function ee {
tmux split-window "$EDITOR $@"
@howardabrams
howardabrams / increment-number.el
Last active December 10, 2016 11:36
A simple approach to easily incrementing (or decrementing) the next number in an Emacs buffer. This seems to be helpful when editing odd XML data files.
(defun increment-decrement (amount)
(let* ((for-number "[0-9][0-9]*")
(end (re-search-forward for-number))
(start (match-beginning 0))
(str (buffer-substring start end))
(num (+ amount (string-to-number str))))
(delete-region start end)
(insert (number-to-string num))
(goto-char start)))
@howardabrams
howardabrams / little-eshell.el
Last active December 10, 2016 11:36
A function for creating small, temporary eshell buffers that will be "somewhat associated" with a particular buffer (since it is named after the directory that file is in).
(defun eshell-here ()
"Opens up a new shell in the directory associated with the current buffer's file."
(interactive)
(let* ((parent (if (buffer-file-name)
(file-name-directory (buffer-file-name))
default-directory))
(height (/ (window-total-height) 3))
(name (car (last (split-string parent "/" t)))))
(split-window-vertically (- height))
(other-window 1)
@howardabrams
howardabrams / .emacs
Last active December 10, 2016 11:35
In my Emacs initialization, I run through a few functions that automatically set up my windows and environment. This `setup-windows` function is unique for each machine that I work on, but I bind it to <F6>, so that I can easily start this. Why yes, if I run this function, I rebind it.
(defun setup-windows ()
"Setup my entire Emacs environment. Function is often called when I first start it up."
(interactive)
(frame-fullscreen)
(split-window-horizontally 168) ;; On this machine, I know how big
(split-window-horizontally 84) ;; my monitor is, so ...
(other-window 2)
(split-window-vertically)
(circe-connect-all) ;; Connect to all my IRC channels
(twit) ;; Start twitter in this window
@howardabrams
howardabrams / surround.el
Last active December 10, 2016 11:35
Now that we can easily make a region based on "syntactic components" using the `expand-region` command, wrapping a logical block of text with a beginning and ending string really makes sense.
(defun surround (start end txt)
"Wraps the specified region (or the current 'symbol / word'
with some textual markers that this function requests from the
user. Opening-type text, like parens and angle-brackets will
insert the matching closing symbol.
This function also supports some org-mode wrappers:
- `#s` wraps the region in a source code block
- `#e` wraps it in an example block
@howardabrams
howardabrams / surround-v2.el
Last active December 10, 2016 11:35
Now that we can easily make a region based on "syntactic components" using the `expand-region` command, wrapping a logical block of text with a beginning and ending string really makes sense. This "version" is more Emacs-y in that it `lets` all the variables, and then `setq` them to their proper values. While I'm not pedantic, I don't like such …
(defun surround (start end txt)
"Wraps the specified region (or the current 'symbol / word'
with some textual markers that this function requests from the
user. Opening-type text, like parens and angle-brackets will
insert the matching closing symbol.
This function also supports some org-mode wrappers:
- `#s` wraps the region in a source code block
- `#e` wraps it in an example block
@howardabrams
howardabrams / keybase.md
Created April 9, 2014 04:30
Proof of my keybase.io credentials... you can ignore this.

Keybase proof

I hereby claim:

  • I am howardabrams on github.
  • I am howardabrams (https://keybase.io/howardabrams) on keybase.
  • I have a public key whose fingerprint is 2B03 9DE6 5EE1 161B 2807 3888 5B10 2887 E4B9 1525

To claim this, I am signing this object:

;;; SAVE-HOOKS --- Folder Actions on Save
;;
;; Author: Howard Abrams <howard.abrams@gmail.com>
;; Copyright © 2015, Howard Abrams, all rights reserved.
;; Created: 18 March 2015
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;;; SAVE-HOOKS --- Folder Actions on Save
;;
;; Author: Howard Abrams <howard.abrams@gmail.com>
;; Copyright © 2015, Howard Abrams, all rights reserved.
;; Created: 18 March 2015
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;;; Commentary:
;;
;; I would like a function that inserts a phrase or paragraph into a
;; buffer, but that it is looks like it is being typed. This means to
;; have a slight, but random time delay between each letter. Calling
;; `sit-for' is sufficient for short sentences (around 140
;; characters), but anything longer makes the display look like it
;; hangs until some event, and then the entire results are displayed.
;;
;; Ideas or thoughts on what to look for?
(defun insert-typewriter (str)