File: init.el

package info (click to toggle)
flycheck 35.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,344 kB
  • sloc: lisp: 16,730; python: 739; makefile: 243; cpp: 24; ruby: 23; perl: 21; ada: 17; f90: 16; javascript: 15; haskell: 15; erlang: 14; xml: 14; ansic: 12; sh: 10; php: 9; tcl: 8; fortran: 3; vhdl: 2; awk: 1; sql: 1
file content (152 lines) | stat: -rw-r--r-- 5,609 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
;;; init.el --- Flycheck: Init file for testing      -*- lexical-binding: t; -*-

;; Copyright (C) 2017 Flycheck contributors
;; Copyright (C) 2015-2016 Sebastian Wiesner and Flycheck contributors

;; Author: Sebastian Wiesner <swiesner@lunaryorn.com>
;; Maintainer: Clément Pit-Claudel <clement.pitclaudel@live.com>
;;             fmdkdd <fmdkdd@gmail.com>
;; URL: https://www.flycheck.org

;; This file is not part of GNU Emacs.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; Use with `emacs -Q -l test/init.el -f flycheck/init' to start a clean session
;; with only Flycheck present.
;;
;; Installs all dependencies of Flycheck to a temporary package directory, and
;; loads Flycheck.

;;; Code:

(require 'package)

(defconst flycheck/init-file (if load-in-progress
                                 load-file-name
                               buffer-file-name)
  "The path of this file.")

(defun flycheck/init ()
  "Initialize a minimal Flycheck session.

Install Flycheck and its dependencies into a separate package
directory (init-elpa in the current directory) and enable
Flycheck globally.

Set some global customization options to get rid of some of the
worst defaults of Emacs and create a half-way bearable Emacs
session.

Define a `demo' checker which can be used to demonstrate Flycheck
in this file."
  (setq load-prefer-newer t)            ; Don't load outdated bytecode

  (setq package-user-dir (expand-file-name "init-elpa" (file-name-directory
                                                        flycheck/init-file))
        package-check-signature nil)
  (add-to-list 'package-archives
               '("MELPA" . "https://stable.melpa.org/packages/"))

  (package-initialize)

  (let* ((source-dir (locate-dominating-file flycheck/init-file "flycheck.el"))
         (flycheck-el (expand-file-name "flycheck.el" source-dir)))
    ;; Install Flycheck to bring its dependencies in
    (unless (package-installed-p 'flycheck)
      (package-refresh-contents)
      (package-install-file flycheck-el))
    (load flycheck-el))

  (require 'flycheck)
  (global-flycheck-mode)

  ;; Some dummy code for warnings which we use to demonstrate Flycheck, see
  ;; `demo' checker below.
  (list 'an-info-here
        'a-warning-here
        'an-error-here)

  ;; Some little convenience, to this Emacs session at least half way bearable
  (require 'ido)
  (ido-mode t)
  (setq ido-enable-flex-matching t)

  ;; Get rid of all the silly UI clutter of a default Emacs session and opt out
  ;; of all the stupid startup and license messages
  (tool-bar-mode -1)
  (blink-cursor-mode -1)
  (setq ring-bell-function #'ignore
        inhibit-startup-screen t
        initial-scratch-message "")
  (fset 'yes-or-no-p #'y-or-n-p)
  (fset 'display-startup-echo-area-message #'ignore)

  ;; Improve OS X key behaviour
  (when (eq system-type 'darwin)
    (setq mac-option-modifier 'meta     ; Option is simply the natural Meta
          mac-command-modifier 'meta    ; But command is a lot easier to hit
          mac-right-command-modifier 'left
          mac-right-option-modifier 'none ; Keep right option for accented input
          mac-function-modifier 'hyper))

  (flycheck-define-generic-checker 'demo
    "A demo syntax checker."
    :start (lambda (checker callback)
             (funcall callback 'finished
                      (save-excursion
                        (goto-char (point-min))
                        (search-forward "an-info-here")
                        (list (flycheck-error-new-at
                               (line-number-at-pos) 10 'info
                               "An info here" :checker checker)
                              (flycheck-error-new-at
                               (+ 1 (line-number-at-pos)) 10 'warning
                               "A warning here" :checker checker)
                              (flycheck-error-new-at
                               (+ 2 (line-number-at-pos)) 10 'error
                               "A error here" :checker checker)))))
    :modes 'emacs-lisp-mode))

(defun flycheck-prepare-screenshot (&optional hide-cursor)
  "Prepare this Emacs session for a screenshot.

If HIDE-CURSOR is non-nil or if a prefix arg is given hide the
cursor, otherwise keep it."
  (interactive "P")
  ;; Reduce UI and disable cursor
  (menu-bar-mode -1)
  (scroll-bar-mode -1)
  (setq-default truncate-lines t)
  (when hide-cursor
    (setq-default cursor-type nil))

  (set-frame-font "Source Code Pro-13")
  (set-frame-size (selected-frame) 750 560 'pixelwise)
  ;; Tuck the error list to the bottom side window at a fixed height
  (add-to-list 'display-buffer-alist
               `(,(rx bos "*Flycheck errors*")
                 (display-buffer-reuse-window
                  display-buffer-in-side-window)
                 (side            . bottom)
                 (reusable-frames . visible)
                 (window-height   . 0.33))))

;; Local Variables:
;; no-byte-compile: t
;; End:

;;; init.el ends here