mirror of
https://github.com/golang/go
synced 2024-11-15 04:40:28 -07:00
[release-branch.go1.2] misc/emacs: various cleanups
««« CL 20100043 / 9fe43a708b89 misc/emacs: various cleanups - Use #' for function symbols - Remove unused variables - Use declare-function to shut up byte compiler This is identical to CL 19010044 with one exception: Making sure it doesn't break on Emacs 22.1 R=adonovan, bradfitz, shendaras CC=golang-dev https://golang.org/cl/20100043 »»» R=golang-dev CC=golang-dev https://golang.org/cl/25750043
This commit is contained in:
parent
1bca9371e7
commit
1c961995ae
@ -41,8 +41,8 @@
|
|||||||
|
|
||||||
(defalias 'go--kill-whole-line
|
(defalias 'go--kill-whole-line
|
||||||
(if (fboundp 'kill-whole-line)
|
(if (fboundp 'kill-whole-line)
|
||||||
'kill-whole-line
|
#'kill-whole-line
|
||||||
'kill-entire-line))
|
#'kill-entire-line))
|
||||||
|
|
||||||
;; Delete the current line without putting it in the kill-ring.
|
;; Delete the current line without putting it in the kill-ring.
|
||||||
(defun go--delete-whole-line (&optional arg)
|
(defun go--delete-whole-line (&optional arg)
|
||||||
@ -56,12 +56,16 @@
|
|||||||
(kill-new (s) ()))
|
(kill-new (s) ()))
|
||||||
(go--kill-whole-line arg)))
|
(go--kill-whole-line arg)))
|
||||||
|
|
||||||
|
;; declare-function is an empty macro that only byte-compile cares
|
||||||
|
;; about. Wrap in always false if to satisfy Emacsen without that
|
||||||
|
;; macro.
|
||||||
|
(if nil
|
||||||
|
(declare-function go--position-bytes "go-mode" (point)))
|
||||||
;; XEmacs unfortunately does not offer position-bytes. We can fall
|
;; XEmacs unfortunately does not offer position-bytes. We can fall
|
||||||
;; back to just using (point), but it will be incorrect as soon as
|
;; back to just using (point), but it will be incorrect as soon as
|
||||||
;; multibyte characters are being used.
|
;; multibyte characters are being used.
|
||||||
(if (fboundp 'position-bytes)
|
(if (fboundp 'position-bytes)
|
||||||
(defalias 'go--position-bytes 'position-bytes)
|
(defalias 'go--position-bytes #'position-bytes)
|
||||||
(defun go--position-bytes (point) point))
|
(defun go--position-bytes (point) point))
|
||||||
|
|
||||||
(defun go--old-completion-list-style (list)
|
(defun go--old-completion-list-style (list)
|
||||||
@ -279,15 +283,15 @@ For mode=set, all covered lines will have this weight."
|
|||||||
|
|
||||||
(defvar go-mode-map
|
(defvar go-mode-map
|
||||||
(let ((m (make-sparse-keymap)))
|
(let ((m (make-sparse-keymap)))
|
||||||
(define-key m "}" 'go-mode-insert-and-indent)
|
(define-key m "}" #'go-mode-insert-and-indent)
|
||||||
(define-key m ")" 'go-mode-insert-and-indent)
|
(define-key m ")" #'go-mode-insert-and-indent)
|
||||||
(define-key m "," 'go-mode-insert-and-indent)
|
(define-key m "," #'go-mode-insert-and-indent)
|
||||||
(define-key m ":" 'go-mode-insert-and-indent)
|
(define-key m ":" #'go-mode-insert-and-indent)
|
||||||
(define-key m "=" 'go-mode-insert-and-indent)
|
(define-key m "=" #'go-mode-insert-and-indent)
|
||||||
(define-key m (kbd "C-c C-a") 'go-import-add)
|
(define-key m (kbd "C-c C-a") #'go-import-add)
|
||||||
(define-key m (kbd "C-c C-j") 'godef-jump)
|
(define-key m (kbd "C-c C-j") #'godef-jump)
|
||||||
(define-key m (kbd "C-x 4 C-c C-j") 'godef-jump-other-window)
|
(define-key m (kbd "C-x 4 C-c C-j") #'godef-jump-other-window)
|
||||||
(define-key m (kbd "C-c C-d") 'godef-describe)
|
(define-key m (kbd "C-c C-d") #'godef-describe)
|
||||||
m)
|
m)
|
||||||
"Keymap used by Go mode to implement electric keys.")
|
"Keymap used by Go mode to implement electric keys.")
|
||||||
|
|
||||||
@ -396,7 +400,7 @@ current line will be returned."
|
|||||||
|
|
||||||
(defun go-indentation-at-point ()
|
(defun go-indentation-at-point ()
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let (start-nesting (outindent 0))
|
(let (start-nesting)
|
||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
(setq start-nesting (go-paren-level))
|
(setq start-nesting (go-paren-level))
|
||||||
|
|
||||||
@ -426,7 +430,6 @@ current line will be returned."
|
|||||||
(interactive)
|
(interactive)
|
||||||
(let (indent
|
(let (indent
|
||||||
shift-amt
|
shift-amt
|
||||||
end
|
|
||||||
(pos (- (point-max) (point)))
|
(pos (- (point-max) (point)))
|
||||||
(point (point))
|
(point (point))
|
||||||
(beg (line-beginning-position)))
|
(beg (line-beginning-position)))
|
||||||
@ -517,7 +520,7 @@ consider binding godef-jump to `M-.', which is the default key
|
|||||||
for `find-tag':
|
for `find-tag':
|
||||||
|
|
||||||
\(add-hook 'go-mode-hook (lambda ()
|
\(add-hook 'go-mode-hook (lambda ()
|
||||||
(local-set-key (kbd \"M-.\") 'godef-jump)))
|
(local-set-key (kbd \"M-.\") #'godef-jump)))
|
||||||
|
|
||||||
Please note that godef is an external dependency. You can install
|
Please note that godef is an external dependency. You can install
|
||||||
it with
|
it with
|
||||||
@ -537,7 +540,7 @@ recommended that you look at goflymake
|
|||||||
'(go--build-font-lock-keywords))
|
'(go--build-font-lock-keywords))
|
||||||
|
|
||||||
;; Indentation
|
;; Indentation
|
||||||
(set (make-local-variable 'indent-line-function) 'go-mode-indent-line)
|
(set (make-local-variable 'indent-line-function) #'go-mode-indent-line)
|
||||||
|
|
||||||
;; Comments
|
;; Comments
|
||||||
(set (make-local-variable 'comment-start) "// ")
|
(set (make-local-variable 'comment-start) "// ")
|
||||||
@ -545,12 +548,12 @@ recommended that you look at goflymake
|
|||||||
(set (make-local-variable 'comment-use-syntax) t)
|
(set (make-local-variable 'comment-use-syntax) t)
|
||||||
(set (make-local-variable 'comment-start-skip) "\\(//+\\|/\\*+\\)\\s *")
|
(set (make-local-variable 'comment-start-skip) "\\(//+\\|/\\*+\\)\\s *")
|
||||||
|
|
||||||
(set (make-local-variable 'beginning-of-defun-function) 'go-beginning-of-defun)
|
(set (make-local-variable 'beginning-of-defun-function) #'go-beginning-of-defun)
|
||||||
(set (make-local-variable 'end-of-defun-function) 'go-end-of-defun)
|
(set (make-local-variable 'end-of-defun-function) #'go-end-of-defun)
|
||||||
|
|
||||||
(set (make-local-variable 'parse-sexp-lookup-properties) t)
|
(set (make-local-variable 'parse-sexp-lookup-properties) t)
|
||||||
(if (boundp 'syntax-propertize-function)
|
(if (boundp 'syntax-propertize-function)
|
||||||
(set (make-local-variable 'syntax-propertize-function) 'go-propertize-syntax))
|
(set (make-local-variable 'syntax-propertize-function) #'go-propertize-syntax))
|
||||||
|
|
||||||
(set (make-local-variable 'go-dangling-cache) (make-hash-table :test 'eql))
|
(set (make-local-variable 'go-dangling-cache) (make-hash-table :test 'eql))
|
||||||
(add-hook 'before-change-functions (lambda (x y) (setq go-dangling-cache (make-hash-table :test 'eql))) t t)
|
(add-hook 'before-change-functions (lambda (x y) (setq go-dangling-cache (make-hash-table :test 'eql))) t t)
|
||||||
@ -904,13 +907,13 @@ If IGNORE-CASE is non-nil, the comparison is case-insensitive."
|
|||||||
(mapcar (lambda (file)
|
(mapcar (lambda (file)
|
||||||
(let ((sub (substring file (length pkgdir) -2)))
|
(let ((sub (substring file (length pkgdir) -2)))
|
||||||
(unless (or (go--string-prefix-p "obj/" sub) (go--string-prefix-p "tool/" sub))
|
(unless (or (go--string-prefix-p "obj/" sub) (go--string-prefix-p "tool/" sub))
|
||||||
(mapconcat 'identity (cdr (split-string sub "/")) "/"))))
|
(mapconcat #'identity (cdr (split-string sub "/")) "/"))))
|
||||||
(if (file-directory-p dir)
|
(if (file-directory-p dir)
|
||||||
(directory-files dir t "\\.a$"))))
|
(directory-files dir t "\\.a$"))))
|
||||||
(if (file-directory-p pkgdir)
|
(if (file-directory-p pkgdir)
|
||||||
(go--directory-dirs pkgdir)))))
|
(go--directory-dirs pkgdir)))))
|
||||||
(go-root-and-paths)))
|
(go-root-and-paths)))
|
||||||
'string<))
|
#'string<))
|
||||||
|
|
||||||
(defun go-unused-imports-lines ()
|
(defun go-unused-imports-lines ()
|
||||||
;; FIXME Technically, -o /dev/null fails in quite some cases (on
|
;; FIXME Technically, -o /dev/null fails in quite some cases (on
|
||||||
@ -1000,7 +1003,7 @@ description at POINT."
|
|||||||
(let ((description (cdr (butlast (godef--call point) 1))))
|
(let ((description (cdr (butlast (godef--call point) 1))))
|
||||||
(if (not description)
|
(if (not description)
|
||||||
(message "No description found for expression at point")
|
(message "No description found for expression at point")
|
||||||
(message "%s" (mapconcat 'identity description "\n"))))
|
(message "%s" (mapconcat #'identity description "\n"))))
|
||||||
(file-error (message "Could not run godef binary"))))
|
(file-error (message "Could not run godef binary"))))
|
||||||
|
|
||||||
(defun godef-jump (point &optional other-window)
|
(defun godef-jump (point &optional other-window)
|
||||||
@ -1151,6 +1154,6 @@ for."
|
|||||||
(go--coverage-make-overlay range (cadr ranges-and-divisor))))
|
(go--coverage-make-overlay range (cadr ranges-and-divisor))))
|
||||||
|
|
||||||
(if (not (eq cur-buffer (current-buffer)))
|
(if (not (eq cur-buffer (current-buffer)))
|
||||||
(display-buffer (current-buffer) 'display-buffer-reuse-window)))))
|
(display-buffer (current-buffer) #'display-buffer-reuse-window)))))
|
||||||
|
|
||||||
(provide 'go-mode)
|
(provide 'go-mode)
|
||||||
|
Loading…
Reference in New Issue
Block a user