Just a bit of syntactic sugar for Go's composition and methods.
// Base class Foo
type foo class {
(f) Test() {
fmt.Println("foo!")
}
}
(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) |
// Emulating loop breaks with loop condition | |
object A { | |
def main(args: Array[String]) = { | |
val start = System.currentTimeMillis | |
val until = Int.MaxValue | |
var i = 0 | |
var c = 0 |
final class AnyRefOption[T >: Null <: AnyRef] private(private val value: T) extends AnyVal { | |
def isEmpty = value == null | |
def isDefined: Boolean = !isEmpty | |
def get: T = value | |
def foreach[U](fn: T => U): Unit = { | |
if (isDefined) fn(value) | |
} | |
def let[U](fn: T => U) = if (isDefined) fn(value) else AnyRefOption(null) |
# open eshell in terminal emacsclient | |
alias tesh="te --eval '(restart-eshell)'" |
;; Enable Company in selected major modes | |
(let ((hooks '(java-mode-hook))) | |
(dolist (hook hooks) | |
(add-hook hook (lambda () | |
(company-mode 1))))) |
;;; Rebind 'GOTO beginning/end of buffer' to "C-M-v" | |
(defun edge-of-buffer () | |
(interactive) | |
(if (and current-prefix-arg (eq current-prefix-arg '-)) | |
(beginning-of-buffer) (end-of-buffer))) | |
(global-set-key (kbd "C-M-v") 'edge-of-buffer) |