Emacs with golang with flymake with goscript. emacs settings

Source: Internet
Author: User

It's kinda late. So I make it quick: How to setup an Emacs with syntax check when you write golang script.

 

In Linux of course.

 

(Require 'go-mode-load) <br/> (require 'flymake) <br/> (autoload 'flymake-find-file-hook "flymake" t) <br/> (add-hook 'Find-file-hook 'flymake-find-file-hook) <br/> (setq flymake-Gui-warnings-enabled nil) <br/> (setq flymake-log-level 0) <br/> (defun flymake-golang-Init () <br/> (defadvice flymake-save-buffer-in-file ;;;; fix for my goscript usage <br/> (around flymake-save-buffer-in-file-golang-fix <br /> (File-name) <br/> activate) <br/> (make-directory (file-name-directory file-name) 1) <br/> (save-excursion <br/> (goto-Char 0) <br/> (when (looking-at "^ #! /. * Goscript. * ") <br/> (progn (Forward-line 1) (Forward-Char-1) <br/> (write-region (point) (point-max) file-name nil 566) <br/> (flymake-log 3 "saved buffer % s in file % s" (buffer-name) file-name )) <br/> (let * (temp-file (flymake-init-create-temp-buffer-copy <br/> 'flymake-create-temp-inplace )) <br/> (Local-file (file-relative-name <br/> temp-file <br/> (file-name-directory buffer-file-name )))) <Br/>; edit this if you use '8g'/'6g' other than my 'cg '<br/> ;;#! /Bin/bash <br/>; 6G $ * <br/> ;; exit 0 <br/> (list "CG" (list "-O/dev/null" Local-file )))) <br/> (setq flymake-allowed-file-name-masks <br/> (Cons '(". + //. go $ "<br/> flymake-golang-init <br/> flymake-simple-cleanup <br/> flymake-get-real-file-name) <br/> flymake-allowed-file-name-masks) <br/> (defun flymake-display-current-error () <br/> "display errors/warnings under cursor. "<br/> (interactive) <br/> (LET (ovs (overlays-in (point) (1 + (point ))))) <br/> (catch 'found <br/> (dolist (OV ovs) <br/> (when (flymake-overlay-p ov) <br/> (message (overlay-Get ov 'help-echo) <br/> (throw'found t )))))) <br/> (Global-set-Key (KBD "C-C f") 'flymake-display-current-error) <br/> (Global-set-Key (KBD "c-c m") 'flymake-mode) <br/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.