small code improvements

This commit is contained in:
Łukasz Pankowski 2019-12-15 20:15:28 +01:00
parent cc78bafa5b
commit dff227a67c
2 changed files with 11 additions and 24 deletions

13
init.el
View File

@ -350,7 +350,7 @@ of the key binding used to execute this command."
(let ((character ?a)) (let ((character ?a))
(while (<= character ?z) (while (<= character ?z)
(define-key my-switch-to-register-map (define-key my-switch-to-register-map
(format "%c" character) #'my-switch-to-register) (char-to-string character) #'my-switch-to-register)
(setq character (1+ character)))) (setq character (1+ character))))
(global-set-key (kbd "s-s") my-switch-to-register-map) (global-set-key (kbd "s-s") my-switch-to-register-map)
@ -486,7 +486,7 @@ of the key binding used to execute this command."
slime-default-lisp 'sbcl slime-default-lisp 'sbcl
slime-contribs '(slime-fancy)) slime-contribs '(slime-fancy))
(let ((path (expand-file-name "/usr/local/share/doc/HyperSpec/"))) (let ((path "/usr/local/share/doc/HyperSpec/"))
(if (file-accessible-directory-p path) (if (file-accessible-directory-p path)
(setq common-lisp-hyperspec-root (concat "file://" path)))) (setq common-lisp-hyperspec-root (concat "file://" path))))
@ -575,9 +575,8 @@ If there is a space before the brace also adds new line with
properly indented closing brace and moves cursor to another line properly indented closing brace and moves cursor to another line
inserted between the braces between the braces." inserted between the braces between the braces."
(interactive) (interactive)
(if (not (looking-back " ")) (insert "{")
(insert "{") (when (looking-back " {")
(insert "{")
(newline) (newline)
(indent-according-to-mode) (indent-according-to-mode)
(save-excursion (save-excursion
@ -1030,9 +1029,7 @@ Argument FRAMES has the same meaning as for `set-frame-font'"
(interactive) (interactive)
(let ((dark-p (custom-theme-enabled-p my-dark-theme))) (let ((dark-p (custom-theme-enabled-p my-dark-theme)))
(mapc #'disable-theme custom-enabled-themes) (mapc #'disable-theme custom-enabled-themes)
(if dark-p (load-theme (if dark-p my-light-theme my-dark-theme) t))
(load-theme my-light-theme t)
(load-theme my-dark-theme t)))
(my-helm-themes-after)) (my-helm-themes-after))
(global-set-key (kbd "C-S-<f6>") #'my-toggle-theme) (global-set-key (kbd "C-S-<f6>") #'my-toggle-theme)

View File

@ -32,9 +32,8 @@ If there is a space before the brace also adds new line with
properly indented closing brace and moves cursor to another line properly indented closing brace and moves cursor to another line
inserted between the braces between the braces." inserted between the braces between the braces."
(interactive) (interactive)
(if (not (looking-back " ")) (insert "{")
(insert "{") (when (looking-back " {")
(insert "{")
(newline) (newline)
(indent-according-to-mode) (indent-according-to-mode)
(save-excursion (save-excursion
@ -42,19 +41,11 @@ inserted between the braces between the braces."
(insert "}") (insert "}")
(indent-according-to-mode)))) (indent-according-to-mode))))
(defun my-go-list-packages ()
"Return list of Go packages."
(split-string
(with-temp-buffer
(shell-command "go list ... 2>/dev/null" (current-buffer))
(buffer-substring-no-properties (point-min) (point-max)))
"\n"))
(defun my-godoc-package () (defun my-godoc-package ()
"Display godoc for given package (with completion)." "Display godoc for given package (with completion)."
(interactive) (interactive)
(godoc (helm :sources (helm-build-sync-source "Go packages" (godoc (helm :sources (helm-build-sync-source "Go packages"
:candidates (my-go-list-packages)) :candidates (go-packages))
:buffer "*godoc packages*"))) :buffer "*godoc packages*")))
(use-package flycheck (use-package flycheck
@ -67,16 +58,15 @@ inserted between the braces between the braces."
:defer) :defer)
(use-package go-guru (use-package go-guru
:defer) :after go-mode)
(use-package go-mode (use-package go-mode
:init :init
(setq gofmt-command "goimports" ; use goimports instead of gofmt (setq gofmt-command "goimports" ; use goimports instead of gofmt
go-fontify-function-calls nil ; fontifing names of called go-fontify-function-calls nil ; fontifing names of called
; functions is too much for me ; functions is too much for me
company-idle-delay nil) company-idle-delay nil) ; avoid auto completion popup, use TAB
:config ; to show it
(require 'go-guru)
:bind :bind
(:map go-mode-map (:map go-mode-map
("M-." . go-guru-definition) ("M-." . go-guru-definition)