Skip to content

Instantly share code, notes, and snippets.

View glucas's full-sized avatar

Greg Lucas glucas

View GitHub Profile
(defun my/fix-space ()
"Delete all spaces and tabs around point, leaving one space except at the beginning of a line."
(interactive)
(just-one-space)
(when (looking-back "^[[:space:]]+") (delete-horizontal-space)))
(defun my/delete-backward ()
"When there is an active region, delete it and then fix up the whitespace."
(interactive)
(when (use-region-p)
@glucas
glucas / gist:09aea018251cf85c7290
Last active August 29, 2015 14:15
ace-command-other-window
(defun ace-command-other-window (cmd &optional one-win-cmd)
"Execute CMD in another window.
If provided, call ONE-WIN-CMD instead when there is only one window."
(interactive "CM-x (other window) ")
(catch 'done
(when (and one-win-cmd
(not (window-parent)))
(call-interactively one-win-cmd)
(throw 'done t))
(let ((start-window (selected-window))

Keybase proof

I hereby claim:

  • I am glucas on github.
  • I am glucas (https://keybase.io/glucas) on keybase.
  • I have a public key whose fingerprint is ABF8 9DF2 6AC9 D152 72E8 81A0 7934 B82B D272 9051

To claim this, I am signing this object:

@glucas
glucas / gist:6730692
Created September 27, 2013 15:45
Elisp snippets for defining ibuffer filter groups for all known projectile projects.
(defun my/define-projectile-filter-groups ()
(when (boundp 'projectile-known-projects)
(setq my/project-filter-groups
(--map (list
(concat "Project: " (file-name-nondirectory (directory-file-name it)))
`(filename . ,it))
projectile-known-projects))))
(defun rejeep-projectile-completion-fn (prompt choises)
"Projectile completion function that only shows file name.
If two files have same name, new completion appears to select between
them. These include the path relative to the project root."
(interactive)
(let* ((stripped-choises
(-uniq (--map (file-name-nondirectory it) choises)))
(choise
(ido-completing-read prompt stripped-choises))
@glucas
glucas / gist:4506530
Created January 10, 2013 22:56
Jumping to the most recent buffer.
(defalias 'last-buffer 'mode-line-other-buffer)
(global-set-key (kbd "M-O") 'last-buffer)
(defun my/split-window()
"Split the window to see the most recent buffer in the other window.
Call a second time to restore the original window configuration."
(interactive)
(if (eq last-command 'my/split-window)
(progn