From dff227a67c84633f75086398f0f4975e65229423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pankowski?= Date: Sun, 15 Dec 2019 20:15:28 +0100 Subject: [PATCH] small code improvements --- init.el | 13 +++++-------- old-go.el | 22 ++++++---------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/init.el b/init.el index 8017b36..0592f93 100644 --- a/init.el +++ b/init.el @@ -350,7 +350,7 @@ of the key binding used to execute this command." (let ((character ?a)) (while (<= character ?z) (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)))) (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-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) (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 inserted between the braces between the braces." (interactive) - (if (not (looking-back " ")) - (insert "{") - (insert "{") + (insert "{") + (when (looking-back " {") (newline) (indent-according-to-mode) (save-excursion @@ -1030,9 +1029,7 @@ Argument FRAMES has the same meaning as for `set-frame-font'" (interactive) (let ((dark-p (custom-theme-enabled-p my-dark-theme))) (mapc #'disable-theme custom-enabled-themes) - (if dark-p - (load-theme my-light-theme t) - (load-theme my-dark-theme t))) + (load-theme (if dark-p my-light-theme my-dark-theme) t)) (my-helm-themes-after)) (global-set-key (kbd "C-S-") #'my-toggle-theme) diff --git a/old-go.el b/old-go.el index 54615cc..6ecb1d1 100644 --- a/old-go.el +++ b/old-go.el @@ -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 inserted between the braces between the braces." (interactive) - (if (not (looking-back " ")) - (insert "{") - (insert "{") + (insert "{") + (when (looking-back " {") (newline) (indent-according-to-mode) (save-excursion @@ -42,19 +41,11 @@ inserted between the braces between the braces." (insert "}") (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 () "Display godoc for given package (with completion)." (interactive) (godoc (helm :sources (helm-build-sync-source "Go packages" - :candidates (my-go-list-packages)) + :candidates (go-packages)) :buffer "*godoc packages*"))) (use-package flycheck @@ -67,16 +58,15 @@ inserted between the braces between the braces." :defer) (use-package go-guru - :defer) + :after go-mode) (use-package go-mode :init (setq gofmt-command "goimports" ; use goimports instead of gofmt go-fontify-function-calls nil ; fontifing names of called ; functions is too much for me - company-idle-delay nil) - :config - (require 'go-guru) + company-idle-delay nil) ; avoid auto completion popup, use TAB + ; to show it :bind (:map go-mode-map ("M-." . go-guru-definition)