Just a bit of syntactic sugar for Go's composition and methods.
// Base class Foo
type foo class {
(f) Test() {
fmt.Println("foo!")
}
}
;; Dired - Copy file to the directory of window selected by AceWindow | |
(defun arx/dired-do-copy-ace-window () | |
(interactive) | |
(when-let ((dst-dir (aw-select | |
"Copy file to the directory of other window" | |
(lambda (w) | |
(with-selected-window w | |
default-directory)))) | |
(src-file (or (dired-get-subdir) (dired-get-filename))) | |
(_ (y-or-n-p (format "Copy %s to %s?" src-file dst-dir)))) |
(defun term-emulator-here () | |
"Start terminal emulator in current directory." | |
(interactive) | |
(let* ((term-emulator "alacritty") | |
(display-buffer-alist '(("\\*Async Shell Command\\*.*" display-buffer-no-window))) | |
(command term-emulator)) | |
(async-shell-command command))) |
;; Copy full path of file with W | |
(defun arx/dired-copy-full-filename-as-kill () | |
(interactive) | |
(let ((name (or (dired-get-subdir) (dired-get-filename)))) | |
(kill-new name) | |
(message "%s" name))) | |
(keymap-set dired-mode-map "W" 'arx/dired-copy-full-filename-as-kill) |
ZSH_THEME="robbyrussell" | |
# https://zenbro.github.io/2015/07/23/show-exit-code-of-last-command-in-zsh.html | |
function check_last_exit_code() { | |
local LAST_EXIT_CODE=$? | |
if [[ $LAST_EXIT_CODE -ne 0 ]]; then | |
local EXIT_CODE_PROMPT=' ' | |
EXIT_CODE_PROMPT+="%{$fg[red]%}%{$reset_color%}" | |
EXIT_CODE_PROMPT+="%{$fg_bold[red]%}$LAST_EXIT_CODE%{$reset_color%}" | |
EXIT_CODE_PROMPT+="%{$fg[red]%}%{$reset_color%}" |
;; Exchange between `emacs -nw` and X clipboard | |
(defun x-select-text (text) | |
"Send TEXT to X11's clipboard." | |
(let ((process-connection-type nil)) | |
(let ((proc (start-process "xsel" "*Messages*" "xsel" "-i" "-b"))) | |
(process-send-string proc text) | |
(process-send-eof proc)))) | |
(defun x-selection-value () | |
"Get X11' clipboard string to insert it into in `kill-buffer`." |
(defvar window-stack '()) | |
(defun push-window-configuration () | |
(interactive) | |
(push (current-window-configuration) window-stack)) | |
(defun pop-window-configuration () | |
(interactive) | |
(let ((val (pop window-stack))) | |
(and val (set-window-configuration val)))) |
(defun shell-here () | |
"Create new shell rooted at default-directory and open it in | |
new window if there is no other shells associated with | |
default-directory, open existing shell otherwise." | |
(interactive) | |
(let* ((buffer-dir (directory-file-name (expand-file-name default-directory))) | |
(shell-buffer-name (concat "*shell*<" buffer-dir "/>"))) | |
(shell shell-buffer-name))) |
/** ScalaDoc for `object foo`. */ | |
object foo { | |
/** This ScalaDoc will be listed. */ | |
def foo = 42 | |
// This comment won't be listed | |
def bar = 43 | |
/** Multi- | |
* -line |
inline def unroll(inline times: Int)(inline action: Int => Unit): Unit = | |
if (times > 0) | |
action(times) | |
unroll(times - 1)(action) | |
unroll(4)(println) |