-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.emacs
716 lines (631 loc) · 27.6 KB
/
.emacs
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
;;; FILE: .emacs (with a period as the first character of the filename)
;;;
;;; This is a small emacs initialization file. You may use and modify
;;; this file as you like. For a Linux system, put .emacs in your own home
;;; directory. For Windows 95, put .emacs in c:\.emacs.
(modify-frame-parameters nil '((wait-for-wm . nil)))
;;; default font
(set-frame-font "Source Code Pro Light-11")
;; melpha
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
;; auto reverts files when changed on disk
(global-auto-revert-mode)
(auto-revert-mode)
;; ido support
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(ido-mode 1)
(setq ido-create-new-buffer 'always)
(load-theme 'deeper-blue t)
;; allows you to open files in an existing emacs session from a shell
;(server-start)
(setq load-path (cons "/usr/share/emacs/site-lisp" load-path))
;(setq load-path (cons "/usr/share/emacs/site-lisp/ocaml-mode" load-path))
;(setq load-path (cons "~/.emacs.d/themes" load-path))
(setq load-path (cons "~/.emacs.d/lisp" load-path))
(setq inhibit-splash-screen t)
(show-paren-mode 1)
;(require 'erlang-start)
;hunspell
(if (file-exists-p "/usr/bin/hunspell")
(progn
(setq ispell-program-name "hunspell")
(setq ispell-dictionary "american"
ispell-extra-args '("-a" "-i" "utf-8" "-d" "en_US")
ispell-silently-savep t
)))
(setq select-enable-clipboard t)
(setq interprogram-paste-function 'x-selection-value)
;Add cmake listfile names to the mode list.
(autoload 'cmake-mode "cmake-mode.el" t)
;; turn off tool bar, menu bar, scroll bar
(tool-bar-mode 0)
(menu-bar-mode 0)
(scroll-bar-mode -1)
(setq scroll-step 1)
(setq-default scroll-step 1)
;; Tab shit
(setq toggle-tabs nil)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
(setq standard-indent 4)
;; don't trucate shiz
(setq truncate-partial-width-windows nil)
(setq truncate-lines nil)
(autoload 'csharp-mode "csharp-mode"
"Major mode for editing C# code." t)
(setq auto-mode-alist (cons '( "\\.cs\\'" . csharp-mode ) auto-mode-alist ))
(setq auto-mode-alist (cons '( "\\.ml[iyl]?$" . caml-mode ) auto-mode-alist ))
;(if window-system (require 'caml-font))
;; ack
(autoload 'ack-same "full-ack" nil t)
(autoload 'ack "full-ack" nil t)
(autoload 'ack-find-same-file "full-ack" nil t)
(autoload 'ack-find-file "full-ack" nil t)
; ubuntu only
(setq ack-executable (executable-find "ack-grep"))
(setq ack-prompt-for-directory t)
;; see your selections
(setq-default transient-mark-mode t)
;;; Cy's sytax highlighting
;;(require 'font-lock)
;; Turn on font-lock in all modes that support it
(if (fboundp 'global-font-lock-mode)
(global-font-lock-mode t))
(setq font-lock-maximum-decoration t)
;;; Michael's Preferences *** -------------------------------
(setq kill-whole-line t) ;;; Killing line also deletes \n
(setq next-line-add-newlines nil) ;;; Down arrow won't add \n at end
(setq require-final-newline t) ;;; Put \n at end of last line
(setq make-backup-files nil) ;;; Don't make backup files
(setq line-number-mode t) ;;; Put line number in display
(setq major-mode 'text-mode) ;;; New buffers are text mode
;;; Michael's
;;; Function
;;; Definitions: *** --------------------------------------------------
;;; indent-all ;;; Indents buffer (use fset because of indent-region)
;;; open-new-line ;;; Open a new line after the current line
;;; c-return ;;; In c: indent & open indented new line
;;; java-return ;;; In java: indent & open indented new line
;;; prolog-return ;;; In prolog: indent & open indented new line
;;; scheme-return ;;; In scheme: indent & open indented new line
;;; delete-whole-line ;;; Delete all of a line
;;; join-lines ;;; Join this line with the next line
;;; front ;;; Move cursor to front of buffer
;;; quit ;;; Save files and quit emacs
;;; exchange-mp ;;; Exchange the cursor with the region's mark
;;; split ;;; Split window, move to other window, open new file
;;; *** --------------------------------------------------
(fset 'indent-all "\C-xh\C-[\C-\\")
(defun open-new-line( ) (interactive) (end-of-line) (newline-and-indent))
(defun c-return( ) (interactive) (c-indent-line) (newline-and-indent))
(defun java-return( ) (interactive) (c-indent-line) (newline-and-indent))
(defun prolog-return( ) (interactive) (prolog-indent-line) (newline-and-indent))
;;;(defun scheme-return( ) (interactive) (scheme-indent-line) (newline-and-indent))
(defun delete-whole-line( ) (interactive) (beginning-of-line) (kill-line))
(defun join-lines( ) (interactive) (end-of-line) (kill-line))
(defun front( ) (interactive) (beginning-of-buffer))
(defun quit( ) (interactive) (save-buffers-kill-emacs))
(defun exchange-mp( ) (interactive) (exchange-point-and-mark))
(defun split( ) (interactive)
(split-window-vertically)
(other-window 1)
)
(defun kill-something( ) (interactive)
(if (and mark-active transient-mark-mode)
(kill-region (point) (mark))
(delete-backward-char 1)
)
)
(defun to-tab-or-not-to-tab( ) (interactive)
(if (not toggle-tabs)
(setq-default indent-tabs-mode t tab-width 4 toggle-tabs 1)
(setq-default indent-tabs-mode nil toggle-tabs nil)
)
)
;;; Some key bindings *** ------------------------------
;;; Home, end, del keys *** --------------------------
(global-set-key [delete] 'delete-char) ;;; Delete = Delete char before cursor
(global-set-key [kp-delete] 'delete-char);; Delete = Delete char before cursor
;(global-set-key [delete] 'kill-something) ;;; Delete = Delete region or char
;(global-set-key [kp-delete] 'kill-something);; Delete = Delete region or char
(global-set-key [home] 'beginning-of-line) ;;; Home = Beginning of line
(global-set-key [kp-home] 'beginning-of-line); Home = Beginning of line
(global-set-key [kp-end] 'end-of-line) ;;; End = End of line
(global-set-key [end] 'end-of-line) ;;; End = End of line
(global-set-key [f1] 'help-command) ;;; F1 = Help
(global-set-key [C-home] 'front) ;;; Ctrl-Home = Front of buffer
(global-set-key [C-kp-home] 'front) ;;; Ctrl-Home = Front of buffer
(global-set-key [C-kp-end] 'end-of-buffer) ;;; Ctrl-End = End of buffer
(global-set-key [C-end] 'end-of-buffer) ;;; Ctrl End = End of buffer
;;; Keypad keys from VT-100 *** ------------------------------
(global-set-key "\M-[M" 'scroll-down) ;;; PgUp = scroll-down
(global-set-key "\M-[H\M-[2J" 'scroll-up) ;;; PgDn = scroll-up
(global-set-key "\M-[H\M-[H" ;;; Home Home = start of line
'beginning-of-line) ;;; (note: that's Home twice!)
(global-set-key "\M-[K" 'end-of-line) ;;; End = end of line
(global-set-key "\M-[L" 'overwrite-mode) ;;; Insert = toggle overwrite
(global-set-key "\M-OA" 'previous-line) ;;; Up arrow = previous line
(global-set-key "\M-OB" 'next-line) ;;; Down arrow = next line
(global-set-key "\M-OC" 'forward-char) ;;; Right arrow = forward char
(global-set-key "\M-OD" 'backward-char) ;;; Left arrow = backward char
(global-set-key "\e\e[H" 'front) ;;; Esc Home = front of file
(global-set-key "\e\e[K" 'end-of-buffer) ;;; Esc End = end of file
(global-set-key "\M-g" 'goto-line) ;;; alt-g = goto line
(global-set-key (kbd "\e\et") 'to-tab-or-not-to-tab)
;;; ------------------------------
;;; Michael's special actions upon entering various editing modes
;;; c-mode
(add-hook 'c-mode-hook
'(lambda()
(local-set-key [13] 'c-return) ;;; RET with automatic indent
(local-set-key "\ep" 'indent-all) ;;; esc-p pretty-prints file
(c-set-style "bsd") ;;; Kernihan & Richie's style
(setq c-basic-offset 4) ;;; 4 spaces for indentations
(c-set-offset 'substatement-open 0) ;;; No indent for open bracket
)
)
;;; c++-mode
(add-hook 'c++-mode-hook
'(lambda()
(local-set-key [13] 'c-return) ;;; RET with automatic indent
(local-set-key "\ep" 'indent-all) ;;; esc-p pretty-prints file
(c-set-style "bsd") ;;; Kernihan & Richie's style
(setq c-basic-offset 4) ;;; 4 spaces for indentations
(c-set-offset 'substatement-open 0) ;;; No indent for open bracket
)
)
;;; jde-mode
(add-hook 'jde-mode-hook
'(lambda()
(local-set-key [13] 'java-return) ;;; RET with automatic indent
(local-set-key "\ep" 'indent-all) ;;; esc-p pretty-prints file
(c-set-style "k&r") ;;; Kernihan & Richie's style
(setq java-basic-offset 4) ;;; 4 spaces for indentations
(c-set-offset 'substatement-open 0) ;;; No indent for open bracket
)
)
;;; java-mode
(add-hook 'java-mode-hook
'(lambda()
(local-set-key [13] 'java-return) ;;; RET with automatic indent
(local-set-key "\ep" 'indent-all) ;;; esc-p pretty-prints file
; (c-set-style "k&r") ;;; Kernihan & Richie's style
(setq c-basic-offset 4) ;;; 4 spaces for indentations
(c-set-offset 'substatement-open 0) ;;; No indent for open bracket
)
)
;;; csharp-mode
(add-hook 'csharp-mode-hook
'(lambda()
(local-set-key "\ep" 'indent-all) ;;; esc-p pretty-prints file
(setq c-basic-offset 4) ;;; 4 spaces for indentations
)
)
;;; prolog-mode
(add-hook 'prolog-mode-hook
'(lambda()
(local-set-key [13] 'prolog-return) ;;; RET with automatic indent
(local-set-key "\ep" 'indent-all) ;;; esc-p pretty-prints file
)
)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(add-hook 'after-save-hook
'executable-make-buffer-file-executable-if-script-p)
;;; From John Gillett's emacs file
;;; ---------------------------------------------------------------
;;; The following lines allow C-j to cause emacs to cycle among its
;;; buffers. (This is a hack, but it seems to work.)
(defun jg-last (list)
"returns last element of a list"
(while (> (length list) 1)
(setq list (cdr list)))
(car list))
(defun jg-buffer-ring ()
"switches among buffers on buffer list, killing the following
annoying buffers if they are encountered:
*Completions*
*Deletions*
*Buffer List*
*Help*
*Minibuf-0*
*Minibuf-1*
*Minibuf-2*
*scratch*
"
(interactive)
(setq loop t)
(while loop
(switch-to-buffer (jg-last (buffer-list)))
(if (or (equal (buffer-name) "*Completions*")
(equal (buffer-name) " *Deletions*")
(equal (buffer-name) "*Messages*")
(equal (buffer-name) "*Buffer List*")
(equal (buffer-name) "*Help*")
(equal (buffer-name) " *Minibuf-0*")
(equal (buffer-name) " *Minibuf-1*")
(equal (buffer-name) " *Minibuf-2*")
;; length test below prevents infinite loop: I kill buffer
;; *scratch*, emacs restarts it, repeat
(and
(> (length (buffer-list)) 2)
(equal (buffer-name) "*scratch*"))
)
(kill-buffer (buffer-name))
(setq loop nil))))
(global-set-key "\C-l" 'jg-buffer-ring)
;;; Uncomment the next two lines if you are in Windows and want ctrl-x ctrl-f
;;; to open the usual Windows file dialog box. You'll also have to copy
;;; www.cs.colorado.edu/~main/emacs/dlgopen.elc to \app\emacs\site-lisp and
;;; copy www.cs.colorado.edu/~main/emacs/getfiles.exe to \windows\command.
;;; (load "dlgopen")
;;; (global-set-key "\C-x\C-f" 'dlgopen-open-files)
;; color scheme
;(require 'color-theme)
;(if window-system
; (color-theme-gnome2)
; (color-theme-hober))
; (font-lock-comment-delimiter-face ((t (:foreground "medium orchid"))))
; (set-foreground-color "Wheat")
;(set-background-color "Black")
; (set-cursor-color "Orchid")
; (set-face-foreground 'font-lock-function-name-face "spring green")
; (set-face-foreground 'font-lock-type-face "goldenrod"))
;Alex Schroeder's color stuff
(defun egoge-wash-out-colour (colour &optional degree)
"Return a colour string specifying a washed-out version of COLOUR."
(let ((basec (color-values
(face-attribute 'default :foreground)))
(col (color-values colour))
(list nil))
(unless degree (setq degree 2))
(while col
(push (/ (/ (+ (pop col)
(* degree (pop basec)))
(1+ degree))
256)
list))
(apply 'format "#%02x%02x%02x" (nreverse list))))
(defun egoge-wash-out-face (face &optional degree)
"Make the foreground colour of FACE appear a bit more pale."
(let ((colour (face-attribute face :foreground)))
(unless (eq colour 'unspecified)
(set-face-attribute face nil
:foreground (egoge-wash-out-colour colour degree)))))
(defun egoge-find-faces (regexp)
"Return a list of all faces whose names match REGEXP."
(delq nil
(mapcar (lambda (face)
(and (string-match regexp
(symbol-name face))
face))
(face-list))))
(defun egoge-wash-out-fontlock-faces (&optional degree)
(mapc (lambda (elt)
(egoge-wash-out-face elt degree))
(delq 'font-lock-warning-face
(egoge-find-faces "^font-lock"))))
;; change this for the default
(when (> (length (defined-colors)) 16)
(egoge-wash-out-fontlock-faces 0))
;; saves emacs sessions
;; http://www.dotemacs.de/dotfiles/DaveGallucci.emacs.html
;; =====================================================================
;; =====================================================================
;; Saving Emacs Sessions - Useful when you have a bunch of source
;; files open and you don't want to go and manually open each one,
;; especially when they are in various directories. Page 377 of the
;; GNU Emacs Manual says: "The first time you save the state of the
;; Emacs session, you must do it manually, with the command M-x
;; desktop-save. Once you have dome that, exiting Emacs will save the
;; state again -- not only the present Emacs session, but also
;; subsequent sessions. You can also save the state at any time,
;; without exiting Emacs, by typing M-x desktop-save again.
;; =====================================================================
(load "desktop")
;(desktop-load-default)
;(desktop-read)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
'("f0a99f53cbf7b004ba0c1760aa14fd70f2eabafe4e62a2b3cf5cabae8203113b" "0e121ff9bef6937edad8dfcff7d88ac9219b5b4f1570fd1702e546a80dba0832" "4aee8551b53a43a883cb0b7f3255d6859d766b6c5e14bcb01bed572fcbef4328" "64581032564feda2b5f2cf389018b4b9906d98293d84d84142d90d7986032d33" "255104c2f5c857498231bc7efbd374026e4ad43547d6fdb4c08be95bc9c871bd" "72407995e2f9932fda3347e44e8c3f29879c5ed88da71f06ba4887b0596959a4" "ad9fc392386f4859d28fe4ef3803585b51557838dbc072762117adad37e83585" "49eea2857afb24808915643b1b5bd093eefb35424c758f502e98a03d0d3df4b1" "4eaad15465961fd26ef9eef3bee2f630a71d8a4b5b0a588dc851135302f69b16" "9dae95cdbed1505d45322ef8b5aa90ccb6cb59e0ff26fef0b8f411dfc416c552" "ed5af4af1d148dc4e0e79e4215c85e7ed21488d63303ddde27880ea91112b07e" "2b5aa66b7d5be41b18cc67f3286ae664134b95ccc4a86c9339c886dfd736132d" "8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4" "d677ef584c6dfc0697901a44b885cc18e206f05114c8a3b7fde674fce6180879" "a8245b7cc985a0610d71f9852e9f2767ad1b852c2bdea6f4aadc12cce9c4d6d0" default))
'(ecb-options-version "2.32")
'(inhibit-startup-screen t)
'(js-indent-level 4)
'(js2-basic-offset 4)
'(js2-strict-missing-semi-warning nil)
'(js2-strict-trailing-comma-warning nil)
'(load-home-init-file t t)
'(package-selected-packages
'(lsp-mode lua-mode ag use-package hydra highlight-indent-guides json-mode markdown-mode company dockerfile-mode go-mode ace-window magit terraform-mode yaml-mode ack tide typescript-mode whitespace-cleanup-mode web-mode nyan-mode js2-mode jinja2-mode coffee-mode)))
'(show-paren-mode t)
'(tool-bar-mode nil)
;; http://www.dotemacs.de/dotfiles/SteveDodd.emacs.html
;; (Copied from:
;; INTELLIMOUSE SETUP
;; . Wheel forward/backwards scrolls by 10 lines
;; . Shift + wheel forward/backwards scrolls by 1 line
;; (change mwheel-scroll-amount to change these defaults).
;; . Bind control + wheel scroll to undo
;; . Set wheel action focus to follow mouse pointer NOT cursor. (Change
;; mwheel-follow-mouse to "nil" to get wheel to only act on the window
;; containing the text cursor.
;;
;; * Please see the copyright notice below for original copyright stuff.
;; I have made a few small changes to the code, such as the undo binding to
;; the wheel, contact me at [email protected] for the
;; original code, or the maintainer below.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; mwheel.el --- Mouse support for MS intelli-mouse type mice
;; Copyright (C) 1998, Free Software Foundation, Inc.
;; Maintainer: William M. Perry <[email protected]>
;; Keywords: mouse
;; This file is part of XEmacs.
;; XEmacs 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 2, or (at your option)
;; any later version.
;; XEmacs 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 XEmacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;; Synched up with: Not synched.
;; Commentary:
;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'custom)
(defconst mwheel-running-xemacs (string-match "XEmacs" (emacs-version)))
(defcustom mwheel-scroll-amount '(10 . 1)
"Amount to scroll windows by when spinning the mouse wheel.
This is actually a cons cell, where the first item is the amount to scroll
on a normal wheel event, and the second is the amount to scroll when the
wheel is moved with the shift key depressed.
This should be the number of lines to scroll, or `nil' for near
full screen.
A near full screen is `next-screen-context-lines' less than a full screen."
:group 'mouse
:type '(cons
(choice :tag "Normal"
(const :tag "Full screen" :value nil)
(integer :tag "Specific # of lines"))
(choice :tag "Shifted"
(const :tag "Full screen" :value nil)
(integer :tag "Specific # of lines"))))
;; Change to nil to only scroll the window the cursor is in (not the pointer)
(defcustom mwheel-follow-mouse 1
"Whether the mouse wheel should scroll the window that the mouse is over.
This can be slightly disconcerting, but some people may prefer it."
:group 'mouse
:type 'boolean)
(if (not (fboundp 'event-button))
(defun mwheel-event-button (event)
(let ((x (symbol-name (event-basic-type event))))
(if (not (string-match "^mouse-\\([0-9]+\\)" x))
(error "Not a button event: %S" event))
(string-to-number (substring x (match-beginning 1) (match-end 1)))))
(fset 'mwheel-event-button 'event-button))
(if (not (fboundp 'event-window))
(defun mwheel-event-window (event)
(posn-window (event-start event)))
(fset 'mwheel-event-window 'event-window))
(defun mwheel-scroll (event)
(interactive "e")
(let ((curwin (if mwheel-follow-mouse
(prog1
(selected-window)
(select-window (mwheel-event-window event)))))
(amt (if (memq 'shift (event-modifiers event))
(cdr mwheel-scroll-amount)
(car mwheel-scroll-amount))))
(case (mwheel-event-button event)
(4 (scroll-down amt))
(5 (scroll-up amt))
(otherwise (error "Bad binding in mwheel-scroll")))
(if curwin (select-window curwin))))
(defun mwheel-undo (event)
(interactive "e")
(let ((curwin (if mwheel-follow-mouse
(prog1
(selected-window)
(select-window (mwheel-event-window event)))))
)
(case (mwheel-event-button event)
(4 (undo))
(5 (undo))
(otherwise (error "Bad binding in mwheel-scroll")))
(if curwin (select-window curwin))))
(define-key global-map
(if mwheel-running-xemacs 'button4 [mouse-4]) 'mwheel-scroll)
(define-key global-map
(if mwheel-running-xemacs 'button5 [mouse-5]) 'mwheel-scroll)
(define-key global-map
(if mwheel-running-xemacs [(shift button4)] [S-mouse-4]) 'mwheel-scroll)
(define-key global-map
(if mwheel-running-xemacs [(shift button5)] [S-mouse-5]) 'mwheel-scroll)
(define-key global-map
(if mwheel-running-xemacs [(control button4)] [C-mouse-4]) 'mwheel-undo)
(define-key global-map
(if mwheel-running-xemacs [(control button5)] [C-mouse-5]) 'mwheel-undo)
(provide 'mwheel)
;;; cmake mode
;; cmake mode
(setq auto-mode-alist
(append
'(("CMakeLists\\.txt\\'" . cmake-mode))
'(("\\.cmake\\'" . cmake-mode))
auto-mode-alist))
;; bdirito changes
(nyan-mode 1)
;; python
(global-flycheck-mode 1)
(with-eval-after-load 'flycheck
(add-hook 'flycheck-mode-hook #'flycheck-pycheckers-setup))
;; json
(add-hook 'json-mode-hook
(lambda ()
(make-local-variable 'js-indent-level)
(setq js-indent-level 2)))
(add-hook 'json-mode-hook 'flycheck-mode)
;; magit
(global-set-key (kbd "C-x o") 'ace-window)
(global-set-key (kbd "C-x g") 'magit-status)
;; python-mode style indents for coffee-mode 'C-c <' vs 'C-c C-<'
(defvar coffee-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c <") 'coffee-indent-shift-left)
(define-key map (kbd "C-c >") 'coffee-indent-shift-right)
map)
"Customizations for coffee-mode.")
;; yaml hooks
(defun indent-rigidly-n (n)
"Indent the region, or otherwise the current line, by N spaces."
(let* ((use-region (and transient-mark-mode mark-active))
(rstart (if use-region (region-beginning) (point-at-bol)))
(rend (if use-region (region-end) (point-at-eol)))
(deactivate-mark "irrelevant")) ; avoid deactivating mark
(indent-rigidly rstart rend n)))
(defvar yaml-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c <") (lambda() (interactive) (indent-rigidly-n -2)))
(define-key map (kbd "C-c >") (lambda() (interactive) (indent-rigidly-n 2)))
map)
"Customizations for yaml-mode.")
(add-hook 'yaml-mode-hook 'highlight-indent-guides-mode)
(setq highlight-indent-guides-method 'fill)
(setq highlight-indent-guides-responsive "top")
(global-set-key (kbd "C-x t") 'hs-toggle-hiding)
(global-whitespace-cleanup-mode)
(setq whitespace-cleanup-mode-only-if-initially-clean nil)
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
(defun setup-tide-mode ()
(interactive)
(tide-setup)
(flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save mode-enabled))
(eldoc-mode +1)
(tide-hl-identifier-mode +1)
;;(define-key (cdr ido-minor-mode-map-entry) [remap tide-rename-file] nil)
;; company is an optional dependency. You have to
;; install it separately via package-install
;; `M-x package-install [ret] company`
(company-mode +1))
;; aligns annotation to the right hand side
(setq company-tooltip-align-annotations t)
;; formats the buffer before saving
(add-hook 'before-save-hook 'tide-format-before-save)
(add-hook 'typescript-mode-hook #'setup-tide-mode)
(put 'downcase-region 'disabled nil)
(put 'upcase-region 'disabled nil)
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
(add-hook 'web-mode-hook
(lambda ()
(when (string-equal "tsx" (file-name-extension buffer-file-name))
(setup-tide-mode))))
;; enable typescript-tslint checker
(flycheck-add-mode 'typescript-tslint 'web-mode)
(setq lsp-log-io 1)
(require 'lsp-mode)
(setq lsp-clients-angular-language-server-command
'("node"
"/home/bdirito/dev/amp/amp-audio/cordova_app/node_modules/@angular/language-server"
"--ngProbeLocations"
"/home/bdirito/dev/amp/amp-audio/cordova_app/node_modules"
"--tsProbeLocations"
"/home/bdirito/dev/amp/amp-audio/cordova_app/node_modules"
"--stdio"))
;; (nmbase (concat locate-dominating-file default-directory "package.json") "node_modules/")
;; (let ((nmbase "/home/bdirito/dev/locution/parv3/node_modules"))
;; (setq lsp-clients-angular-language-server-command
;; '("node"
;; (concat nmbase "@angular/language-server")
;; "--ngProbeLocations"
;; nmbase
;; "--tsProbeLocations"
;; nmbase
;; "--stdio")
;; )
;; )
;; smerge hydra
;; based from modi
(defmacro >=e (version &rest body)
"Emacs VERSION check wrapper around BODY.
BODY can contain both `if' block (for stuff to execute if emacs
is equal or newer than VERSION) and `else' block (for stuff to
execute if emacs is older than VERSION).
Example:
(>=e \"25.0\"
(defun-compatible-with-25.0)
(defun-not-compatible-in-older-version))"
(declare (indent 2)) ;`if'-style indentation where this macro is used
`(if (version<= ,version emacs-version)
,@body))
(use-package smerge-mode
:bind ("C-x m" . hydra-smerge/body)
:init (progn
(defun bdirito/enable-smerge-maybe ()
"auto enable `smerge-mode` when merge conflict is detected."
(save-excursion
(goto-char (point-min))
(when (re-search-forward "^<<<<<<< " nil :noerror)
(smerge-mode 1))))
(add-hook 'find-file-hook #'bdirito/enable-smerge-maybe :append))
:config
(progn
(>=e "26.0"
nil
;; http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=bdfee01a6567b9f08f82bc84d1196e6cb62587ca
(defalias 'smerge-keep-upper 'smerge-keep-mine)
(defalias 'smerge-keep-lower 'smerge-keep-other)
(defalias 'smerge-diff-base-upper 'smerge-diff-base-mine)
(defalias 'smerge-diff-upper-lower 'smerge-diff-mine-other)
(defalias 'smerge-diff-base-lower 'smerge-diff-base-other))
(defhydra hydra-smerge
(:color pink :hint nil :post (smerge-auto-leave))
"
^Move^ ^Keep^ ^Diff^ ^Other^
^^-----------^^-------------------^^---------------------^^-------
_n_ext _b_ase _<_: upper/base _C_ombine
_p_rev _u_pper _=_: upper/lower _r_esolve
^^ _l_ower _>_: base/lower _k_ill current
^^ _a_ll _R_efine
^^ _RET_: current _E_diff
"
("n" smerge-next)
("p" smerge-prev)
("b" smerge-keep-base)
("u" (lambda () (interactive) (smerge-keep-upper) (smerge-next)))
("l" (lambda () (interactive) (smerge-keep-lower) (smerge-next)))
("a" smerge-keep-all)
("RET" smerge-keep-current)
("\C-m" smerge-keep-current)
("<" smerge-diff-base-upper)
("=" smerge-diff-upper-lower)
(">" smerge-diff-base-lower)
("R" smerge-refine)
("E" smerge-ediff)
("C" smerge-combine-with-next)
("r" smerge-resolve)
("k" smerge-kill-current)
("ZZ" (lambda ()
(interactive)
(save-buffer)
(bury-buffer))
"Save and bury buffer" :color blue)
("q" nil "cancel" :color blue))
))