;; Time-stamp: <2015-04-24 16:45:38 kmodi>

;; Mode-line system monitor
;; https://github.com/zk-phi/symon

(use-package symon
  :config
  (progn
    (setq symon-refresh-rate 4)
    (setq symon-delay 5)
    (setq symon-sparkline-type 'symon-sparkline-type-plain)

    (define-symon-monitor symon-current-date-time-monitor
      :interval 60
      :display (propertize
                (format-time-string "%l:%M %b %d %a     ")
                'face 'font-lock-type-face))

    (setq symon-monitors
          (cond ((memq system-type '(gnu/linux cygwin))
                 '(symon-current-date-time-monitor
                   symon-linux-memory-monitor
                   symon-linux-cpu-monitor
                   symon-linux-network-rx-monitor
                   symon-linux-network-tx-monitor))
                ((memq system-type '(windows-nt))
                 '(symon-current-date-time-monitor
                   symon-windows-memory-monitor
                   symon-windows-cpu-monitor
                   symon-windows-network-rx-monitor
                   symon-windows-network-tx-monitor))))

    (symon-mode)))

(provide 'setup-symon)

;; Time-stamp: <2015-04-25 01:25:58 kmodi>

;; Mode-line system monitor
;; https://github.com/zk-phi/symon

(use-package symon
  :config
  (progn
    (setq symon-sparkline-type 'symon-sparkline-type-plain)

    (define-symon-monitor symon-current-date-time-monitor
      :interval 60
      :display (propertize
                (format-time-string "%l:%M %b %d %a     ")
                'face 'font-lock-type-face))

    (setq symon-monitors
          (cond ((memq system-type '(gnu/linux cygwin))
                 '(symon-current-date-time-monitor
                   symon-linux-memory-monitor
                   symon-linux-cpu-monitor
                   symon-linux-network-rx-monitor
                   symon-linux-network-tx-monitor))
                ((memq system-type '(windows-nt))
                 '(symon-current-date-time-monitor
                   symon-windows-memory-monitor
                   symon-windows-cpu-monitor
                   symon-windows-network-rx-monitor
                   symon-windows-network-tx-monitor))))

    (symon-mode)))

(provide 'setup-symon)

Minor: Remove symon refresh and delay overrides


(when *is-a-mac*
  (setq mac-command-modifier 'meta)
  (setq mac-option-modifier 'none)
  (setq default-input-method "MacOSX")
  ;; Make mouse wheel / trackpad scrolling less jerky
  (setq mouse-wheel-scroll-amount '(0.001))
  (when *is-cocoa-emacs*
    ;; Woohoo!!
    (global-set-key (kbd "M-`") 'ns-next-frame)
    (global-set-key (kbd "M-h") 'ns-do-hide-emacs)
    (eval-after-load 'nxml-mode
      '(define-key nxml-mode-map (kbd "M-h") nil))
    (global-set-key (kbd "M-ˍ") 'ns-do-hide-others) ;; what describe-key reports for cmd-option-h
    (global-set-key (kbd "M-c") 'ns-copy-including-secondary)
    (global-set-key (kbd "M-v") 'ns-paste-secondary)))

(provide 'init-osx-keys)

(when *is-a-mac*
  (setq mac-command-modifier 'meta)
  (setq mac-option-modifier 'none)
  (setq default-input-method "MacOSX")
  ;; Make mouse wheel / trackpad scrolling less jerky
  (setq mouse-wheel-scroll-amount '(0.001))
  (when *is-cocoa-emacs*
    ;; Woohoo!!
    (global-set-key (kbd "M-`") 'ns-next-frame)
    (global-set-key (kbd "M-h") 'ns-do-hide-emacs)
    (eval-after-load 'nxml-mode
      '(define-key nxml-mode-map (kbd "M-h") nil))
    (global-set-key (kbd "M-ˍ") 'ns-do-hide-others) ;; what describe-key reports for cmd-option-h
    ))

(provide 'init-osx-keys)

Remove M-c and M-v bindings under OS X.

Remove M-c and M-v bindings under OS X.

M-v clashes with the default key for scrolling up.

It's arguably better to use the standard yank/kill bindings consistently
within Emacs.


(require 'magit)

(setq magit-auto-revert-immediately t
      magit-auto-revert-mode t
      magit-completing-read-function (quote magit-ido-completing-read)
      magit-push-always-verify nil
      magit-push-arguments (quote ("--set-upstream"))
      magit-save-repository-buffers (quote dontask))

(provide 'clgc-magit)

(require 'magit)

(setq magit-auto-revert-immediately t
      magit-auto-revert-mode t
      magit-completing-read-function (quote magit-ido-completing-read)
      magit-push-always-verify nil
      magit-push-arguments (quote ("--set-upstream"))
      magit-save-repository-buffers (quote dontask))

;; disable magit-insert-tags as it's a performance hog for magit-refs
(setq magit-refs-sections-hook
      '(magit-insert-error-header
        magit-insert-branch-description
        magit-insert-local-branches
        magit-insert-remote-branches
        ;; magit-insert-tags
        ))

(provide 'clgc-magit)

Disable magit-insert-tags due to performance problems


;; Time-stamp: <2015-06-09 16:59:52 kmodi>

;; Ivy (comes packaged with the `swiper' package)

(use-package ivy
  :if (not (bound-and-true-p disable-pkg-ivy))
  :config
  (progn
    ;; Disable ido
    (when (boundp 'ido)
      (ido-mode -1))
    ;; Enable ivy
    (ivy-mode 1)
    (setq ivy-use-virtual-buffers t)
    (use-package counsel
      :config
      (progn
        (setq counsel-find-file-at-point t)
        (setq counsel-find-file-ignore-regexp
              (concat
               ;; file names beginning with # or .
               "\\(?:\\`[#.]\\)"
               ;; file names ending with # or ~
               ;; but still allow backup files named like abc.el~timestamp~
               "\\|\\(?:\\`[^~]+?[#~]\\'\\)"))
        (bind-key "C-x C-f" #'counsel-find-file modi-mode-map)))
    ;; overriding the `C-x C-o` binding with `delete-blank-lines'
    (bind-key "C-x C-o" #'ivy-recentf modi-mode-map)
    ;; Revert the default bindings to C-j and C-m
    (bind-keys
     :map ivy-minibuffer-map
      ("C-m" . ivy-alt-done) ; RET
      ("C-j" . ivy-done))))

(provide 'setup-ivy)

;; Counsel
;; Peek at files with "C-M-n" and "C-M-p". Input a leading dot to see all files.

;; Time-stamp: <2015-06-10 13:19:00 kmodi>

;; Ivy (comes packaged with the `swiper' package)

(use-package ivy
  :if (not (bound-and-true-p disable-pkg-ivy))
  :config
  (progn
    ;; Disable ido
    (when (boundp 'ido)
      (ido-mode -1))
    ;; Enable ivy
    (ivy-mode 1)

    (setq ivy-use-virtual-buffers t)

    ;; (setq ivy-re-builders-alist '((t . ivy--regex-plus))) ; default
    (setq ivy-re-builders-alist '((t . ivy--regex-fuzzy)))

    ;; overriding the `C-x C-o` binding with `delete-blank-lines'
    (bind-key "C-x C-o" #'ivy-recentf modi-mode-map)
    ;; Revert the default bindings to C-j and C-m
    (bind-keys
     :map ivy-minibuffer-map
      ("C-m" . ivy-alt-done) ; RET
      ("C-j" . ivy-done))))

(provide 'setup-ivy)

Enable fuzzy search using ivy

Enable fuzzy search using ivy

- Move counsel setup to a separate file


(dolist (hook '(nxml-mode-hook haml-mode-hook sass-mode-hook magit-mode-hook))
  (add-hook hook (lambda () (rinari-launch))))
(defun update-rails-ctags ()
  (interactive)
  (let ((default-directory (or (rinari-root) default-directory)))
    (shell-command (concat "ctags -a -e -f " rinari-tags-file-name " --tag-relative -R app lib vendor test"))))
(require 'rinari)

(add-hook 'rails-minor-mode-hook (lambda () (local-set-key [f6] 'recompile)))

(provide 'init-rails)

(require 'rinari)
(dolist (hook '(nxml-mode-hook haml-mode-hook sass-mode-hook magit-mode-hook))
  (add-hook hook (lambda () (rinari-launch))))

(defun update-rails-ctags ()
  (interactive)
  (let ((default-directory (or (rinari-root) default-directory)))
    (shell-command (concat "ctags -a -e -f " rinari-tags-file-name " --tag-relative -R app lib vendor test"))))

(add-hook 'rails-minor-mode-hook (lambda () (local-set-key [f6] 'recompile)))

(provide 'init-rails)

Tidy up rails init file

Tidy up rails init file


;; mouse integration
(require 'mwheel)

(if (equal (getenv "TERM_PROGRAM") "iTerm.app")
    (require 'mouse) ;; needed for iterm2 compatibility

    (progn
      (xterm-mouse-mode)
      (defvar mouse-wheel-progressive-speed)
      (setq mouse-wheel-progressive-speed nil)
      (defvar mouse-wheel-scroll-amount)
      (setq mouse-wheel-scroll-amount '(1))

      (mouse-wheel-mode 1)

      (declare-function cua-copy-region (arg) "cua-base.el")
      (defun smart-copy-region ()
        (interactive)
        (cua-copy-region nil)
        (shell-command-on-region
         (region-beginning)
         (region-end)
         "pbcopy")
        (message ""))
      (global-set-key (kbd "M-w") 'smart-copy-region)))

;; mouse integration
(require 'mwheel)

(if (equal (getenv "TERM_PROGRAM") "iTerm.app")
    (progn
      (require 'mouse) ;; needed for iterm2 compatibility
      (message
       "********************************************************************************")
      (message "HERE")
      (message
       "********************************************************************************")
      (xterm-mouse-mode)
      (defvar mouse-wheel-progressive-speed)
      (setq mouse-wheel-progressive-speed nil)
      (defvar mouse-wheel-scroll-amount)
      (setq mouse-wheel-scroll-amount '(1))

      (mouse-wheel-mode 1)

      (declare-function cua-copy-region (arg) "cua-base.el")
      (defun smart-copy-region ()
        (interactive)
        (cua-copy-region nil)
        (shell-command-on-region
         (region-beginning)
         (region-end)
         "pbcopy")
        (message ""))
      (global-set-key (kbd "M-w") 'smart-copy-region)))

Fix mouse support load bug

Fix mouse support load bug


;;; packages.el --- Octave Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(setq octave-packages
  '(
    octave
    ))

(defun octave/init-octave ()
  (use-package octave
    :mode ("\\.m\\'" . octave-mode)
    :commands (run-octave)
    :config (evil-leader/set-key-for-mode 'octave-mode
              ;; helpers
              "mhh" 'octave-help
              "mhi" 'octave-lookfor
              ;; REPL
              "msb" 'octave-send-buffer
              "msf" 'octave-send-defun
              "msi" 'run-octave
              "msl" 'octave-send-line
              "msr" 'octave-send-region)))

;;; packages.el --- Octave Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(setq octave-packages
  '(
    octave
    ))

(defun octave/init-octave ()
  (use-package octave
    :mode ("\\.m\\'" . octave-mode)
    :commands (run-octave)
    :config (spacemacs/set-leader-keys-for-major-mode 'octave-mode
              ;; helpers
              "hh" 'octave-help
              "hi" 'octave-lookfor
              ;; REPL
              "sb" 'octave-send-buffer
              "sf" 'octave-send-defun
              "si" 'run-octave
              "sl" 'octave-send-line
              "sr" 'octave-send-region)))

Change octave-mode keys to mirror other modes.

The keybindings in octave-mode don't follow the same standards as the
others. Also use the function `spacemacs/set-leader-keys-for-major-mode`
for setting mode specific keys.


(setq restclient-packages
  '(
    restclient
    )
  )

(defun restclient/init-restclient ()
  (use-package restclient
    :mode ("\\.http\\'" . restclient-mode)
    :defer t
    :init
    (progn

      (defun restclient-http-send-current-raw-stay-in-window ()
        (interactive)
        (restclient-http-send-current t t))

      (spacemacs/set-leader-keys-for-major-mode 'restclient-mode
        "s" 'restclient-http-send-current-stay-in-window
        "S" 'restclient-http-send-current
        "r" 'restclient-http-send-current-raw-stay-in-window
        "R" 'restclient-http-send-current-raw
        "y" 'restclient-copy-curl-command
        ))
    )
  )

Fix trailing whitespaces in last commit

Fix trailing whitespaces in last commit


(when (eval-when-compile (>= emacs-major-version 24))
  (require-package 'flycheck)
  (add-hook 'after-init-hook 'global-flycheck-mode))

;; Override default flycheck triggers
(setq flycheck-check-syntax-automatically '(save idle-change mode-enabled)
      flycheck-idle-change-delay 0.8)
(provide 'init-flycheck)

(when (eval-when-compile (>= emacs-major-version 24))
  (require-package 'flycheck)
  (add-hook 'after-init-hook 'global-flycheck-mode))

;; Override default flycheck triggers
(setq flycheck-check-syntax-automatically '(save idle-change mode-enabled)
      flycheck-idle-change-delay 0.8)

(after-load 'flycheck
  (flycheck-define-checker ruby
    "A Ruby syntax checker using the standard (MRI) Ruby interpreter.

 See URL `http://www.ruby-lang.org/'."
    :command ("ruby" "-w" "-c" source)
    :error-patterns
    ;; These patterns support output from JRuby, too, to deal with RVM or Rbenv
    ((error line-start
            "SyntaxError in " (file-name) ":" line ": " (message)
            line-end)
     (warning line-start
              (file-name) ":" line ":" (optional column ":")
              " warning: " (message) line-end)
     (error line-start (file-name) ":" line ": " (message) line-end))
    :modes (enh-ruby-mode ruby-mode))
  (add-to-list 'flycheck-checkers 'ruby t))

(provide 'init-flycheck)

Add ruby flycheck checker locally until it is restored upstream


(require 'prodigy)

(prodigy-define-tag :name 'rails
  :ready-message "Listening on 0\\.0\\.0\\.0:[0-9]+, CTRL\\+C to stop")

(prodigy-define-tag
  :name 'zeus
  :on-output
  (prodigy-callback (service)
    (let ((poll-zeus "ps aux | grep -c 'zeus slave:'"))
      (when (>= (string-to-number (shell-command-to-string poll-zeus)) 6)
        (prodigy-set-status service 'ready)))))

(prodigy-define-tag :name 'resque-pool
  :ready-message "Starting worker")

(global-set-key (kbd "C-x P") 'prodigy)

(provide 'clgc-prodigy)

(require 'prodigy)

(prodigy-define-tag :name 'rails
  :ready-message "Listening on 0\\.0\\.0\\.0:[0-9]+, CTRL\\+C to stop")

(prodigy-define-tag
  :name 'zeus
  :on-output
  (prodigy-callback (service)
    (let ((poll-zeus "ps aux | grep -c 'zeus slave:'"))
      (when (>= (string-to-number (shell-command-to-string poll-zeus)) 6)
        (prodigy-set-status service 'ready)))))

(prodigy-define-tag :name 'resque-pool
  :ready-message "Starting worker")

;; ansi-color-apply and filter were causing out-of-range errors for zeus
(setq prodigy-output-filters (remove 'ansi-color-apply prodigy-output-filters))

(global-set-key (kbd "C-x P") 'prodigy)

(provide 'clgc-prodigy)

Stop ansi-color-apply from exploding over *messages* buffer


;;; web-programming.el --- Web programming configuration.
;;; Commentary:
;;; Code:

(use-package web-mode
  :ensure t
  :commands (web-mode)
  :mode
  (("\\.phtml\\'" . web-mode)
   ("\\.tpl\\.php\\'" . web-mode)
   ("\\.[agj]sp\\'" . web-mode)
   ("\\.as[cp]x\\'" . web-mode)
   ("\\.erb\\'" . web-mode)
   ("\\.mustache\\'" . web-mode)
   ("\\.djhtml\\'" . web-mode)
   ("\\.html?\\'" . web-mode))
  :config
  (progn
    (setq web-mode-css-indent-offset 2)
    (setq web-mode-code-indent-offset 4)
    (setq web-mode-comment-style 2)
    (setq web-mode-script-padding 0)
    (setq web-mode-enable-current-element-highlight t)
    (setq web-mode-engines-alist
          '(("django"    . "\\.html\\'"))
          )))

;; inhibit { pairing in web mode
(sp-pair "{" nil :actions :rem)

;; Emmet!!!
(use-package emmet-mode
  :ensure t
  :config
  (progn
    (add-hook 'web-mode-hook 'emmet-mode)))

(provide 'web-programming)
;;; web-programming.el ends here

;;; web-programming.el --- Web programming configuration.
;;; Commentary:
;;; Code:

(use-package web-mode
  :ensure t
  :commands (web-mode)
  :mode
  (("\\.phtml\\'" . web-mode)
   ("\\.tpl\\.php\\'" . web-mode)
   ("\\.[agj]sp\\'" . web-mode)
   ("\\.as[cp]x\\'" . web-mode)
   ("\\.erb\\'" . web-mode)
   ("\\.mustache\\'" . web-mode)
   ("\\.djhtml\\'" . web-mode)
   ("\\.html?\\'" . web-mode))
  :config
  (progn
    (setq web-mode-css-indent-offset 2)
    (setq web-mode-code-indent-offset 4)
    (setq web-mode-comment-style 2)
    (setq web-mode-script-padding 0)
    (setq web-mode-enable-current-element-highlight t)
    (setq web-mode-engines-alist
          '(("django"    . "\\.html\\'"))
          )))

(defun my/web-mode-before-function-p (id action context)
  "Check if the char 2 positions before point is a closing paren."
  (and (eq action 'insert)
       (equal (progn (save-excursion
                       (backward-char)
                       (string (preceding-char))))
              ")")))

(sp-local-pair 'web-mode "{" "}" :when '(my/web-mode-before-function-p))

;; Emmet!!!
(use-package emmet-mode
  :ensure t
  :config
  (progn
    (add-hook 'web-mode-hook 'emmet-mode)))

(provide 'web-programming)
;;; web-programming.el ends here

Add paren matching for curly braces for js in web mode


(tool-bar-mode -1)                      ; Hide toolbar
(set-scroll-bar-mode 'right)            ; Scrollbar on right

(setq inhibit-startup-screen t)         ; Hide startup screen

;; Solarized looks great in GUI, but terrible in the console.
(when window-system
    (load-theme 'solarized-dark t))

;; Change the default frame size so that it fits on my laptop's
;; screen.  This is not exactly optimal since it'll be small on other
;; PCs, but I'm too lazy to find a better way.
(add-to-list 'default-frame-alist '(height . 36))
(add-to-list 'default-frame-alist '(top . 0))
(add-to-list 'default-frame-alist '(width . 120))

;; Show 'emacs : $filename' as the frame title, stolen from EmacsWiki
(setq frame-title-format
      '(:eval
        (concat "emacs : " (if buffer-file-name
                               (replace-regexp-in-string
                                "\\\\" "/"
                                (replace-regexp-in-string
                                 (regexp-quote (getenv "HOME")) "~"
                                 (convert-standard-filename buffer-file-name)))
                             (buffer-name)))))

(provide 'tomku-aesthetic)

(tool-bar-mode -1)                      ; Hide toolbar
(set-scroll-bar-mode 'right)            ; Scrollbar on right

(setq inhibit-startup-screen t)         ; Hide startup screen

;; Solarized looks great in GUI, but terrible in the console.
(setq solarized-use-variable-pitch nil
      solarized-scale-org-headlines nil)
(when window-system
    (load-theme 'solarized-dark t))

;; Change the default frame size so that it fits on my laptop's
;; screen.  This is not exactly optimal since it'll be small on other
;; PCs, but I'm too lazy to find a better way.
(add-to-list 'default-frame-alist '(height . 36))
(add-to-list 'default-frame-alist '(top . 0))
(add-to-list 'default-frame-alist '(width . 120))

;; Show 'emacs : $filename' as the frame title, stolen from EmacsWiki
(setq frame-title-format
      '(:eval
        (concat "emacs : " (if buffer-file-name
                               (replace-regexp-in-string
                                "\\\\" "/"
                                (replace-regexp-in-string
                                 (regexp-quote (getenv "HOME")) "~"
                                 (convert-standard-filename buffer-file-name)))
                             (buffer-name)))))

(provide 'tomku-aesthetic)

Make org-mode in Emacs less ugly with Solarized.


(require 'region-bindings-mode)

(region-bindings-mode-enable)

(add-to-list 'region-bindings-mode-disable-predicates
             'minibufferp)

Disable region bindings in minibuffer

Disable region bindings in minibuffer


(when (maybe-require-package 'ivy)
  (after-load 'ivy
    (setq-default ivy-use-virtual-buffers t
                  ivy-count-format ""
                  projectile-completion-system 'ivy)
    ;; IDO-style directory navigation
    (define-key ivy-minibuffer-map (kbd "C-j") #'ivy-immediate-done)
    (define-key ivy-minibuffer-map (kbd "RET") #'ivy-alt-done)
    (when (maybe-require-package 'diminish)
      (diminish 'ivy-mode)))

  (add-hook 'after-init-hook
            (lambda ()
              (when (bound-and-true-p ido-ubiquitous-mode)
                (ido-ubiquitous-mode -1)
                (ido-mode -1))
              (ivy-mode 1))))

(when (maybe-require-package 'counsel)
  (setq-default counsel-mode-override-describe-bindings t)
  (when (maybe-require-package 'diminish)
    (after-load 'counsel
      (diminish 'counsel-mode)))
  (add-hook 'after-init-hook 'counsel-mode))

;;(when (maybe-require-package 'swiper)
;;  (after-load 'ivy
;;    (define-key ivy-mode-map (kbd "C-s") 'swiper)))

(provide 'init-ivy)

(when (maybe-require-package 'ivy)
  (after-load 'ivy
    (setq-default ivy-use-virtual-buffers t
                  ivy-count-format ""
                  projectile-completion-system 'ivy
                  ivy-initial-inputs-alist
                  '((man . "^")
                    (woman . "^")))
    ;; IDO-style directory navigation
    (define-key ivy-minibuffer-map (kbd "C-j") #'ivy-immediate-done)
    (define-key ivy-minibuffer-map (kbd "RET") #'ivy-alt-done)
    (when (maybe-require-package 'diminish)
      (diminish 'ivy-mode)))

  (add-hook 'after-init-hook
            (lambda ()
              (when (bound-and-true-p ido-ubiquitous-mode)
                (ido-ubiquitous-mode -1)
                (ido-mode -1))
              (ivy-mode 1))))

(when (maybe-require-package 'counsel)
  (setq-default counsel-mode-override-describe-bindings t)
  (when (maybe-require-package 'diminish)
    (after-load 'counsel
      (diminish 'counsel-mode)))
  (add-hook 'after-init-hook 'counsel-mode))

;;(when (maybe-require-package 'swiper)
;;  (after-load 'ivy
;;    (define-key ivy-mode-map (kbd "C-s") 'swiper)))

(provide 'init-ivy)

Remove initial "^" input from most ivy prompts


(when (maybe-require-package 'php-mode)
  (maybe-require-package 'smarty-mode))

(provide 'init-php)

(when (maybe-require-package 'php-mode)
  (maybe-require-package 'smarty-mode)

  (when (maybe-require-package 'company-php)
    (after-load 'company
      (add-hook 'php-mode-hook
                (lambda () (sanityinc/local-push-company-backend 'company-ac-php-backend))))))

(provide 'init-php)

Add company-php for PHP auto-complete

Add company-php for PHP auto-complete


;;; emacs/eshell/autoload/settings.el -*- lexical-binding: t; -*-

;;;###autodef
(defun set-eshell-alias! (&rest aliases)
  "Define aliases for eshell."
  (or (cl-evenp (length aliases))
      (signal 'wrong-number-of-arguments (list 'even (length aliases))))
  (after! eshell
    (while aliases
      (setf (alist-get (pop aliases) +eshell-aliases nil nil #'equal)
            (pop aliases)))
    (when (boundp 'eshell-command-aliases-list)
      (if +eshell--default-aliases
          (setq eshell-command-aliases-list
                (append +eshell--default-aliases
                        +eshell-aliases))
        (setq eshell-command-aliases-list +eshell-aliases)))))

;;; emacs/eshell/autoload/settings.el -*- lexical-binding: t; -*-

;;;###autodef
(defun set-eshell-alias! (&rest aliases)
  "Define aliases for eshell."
  (or (cl-evenp (length aliases))
      (signal 'wrong-number-of-arguments (list 'even (length aliases))))
  (after! eshell
    (while aliases
      (setf (alist-get (pop aliases) +eshell-aliases nil nil #'equal)
            (list (pop aliases))))
    (when (boundp 'eshell-command-aliases-list)
      (if +eshell--default-aliases
          (setq eshell-command-aliases-list
                (append +eshell--default-aliases
                        +eshell-aliases))
        (setq eshell-command-aliases-list +eshell-aliases)))))

Fix listp errors in eshell when using aliases


;;; init.el -*- lexical-binding: t; -*-

(doom!
 :completion
 ivy
 (company +auto)

 :ui
 doom
 modeline
 ophints
 hl-todo
 nav-flash
 neotree
 (popup +all +defaults)
 (pretty-code +fira)
 vc-gutter
 vi-tilde-fringe
 window-select

 :editor
 (evil +everywhere +commands)
 snippets
 file-templates
 multiple-cursors
 rotate-text
 fold

 :emacs
 (dired +icons)
 electric
 vc

 :tools
 (lookup +docsets)
 eval
 make
 magit
 lsp
 editorconfig
 flyspell
 flycheck

 :lang
 (sh +fish)
 emacs-lisp
 markdown
 (csharp +unity)
 (haskell +lsp)
 (org
  +attach
  +babel
  +export
  +present)
 (cc +lsp)
 ocaml
 idris
 (web +html +css)

 :term
 term
 eshell

 :app
 ;;(email +gmail)    ; emacs as an email client
 ;;(rss +org)        ; emacs as an RSS reader
 (write            ; emacs as a word processor (latex + org + markdown)
 +wordnut         ; wordnet (wn) search
 +langtool)       ; a proofreader (grammar/style check) for Emacs

 :collab
 ;;floobits          ; peer programming for a price
 ;;impatient-mode    ; show off code over HTTP

 :config
 (default)
 ;;literate
 )

;;; init.el -*- lexical-binding: t; -*-

(doom!
 :completion
 ivy
 (company +auto)

 :ui
 doom
 modeline
 ophints
 hl-todo
 nav-flash
 neotree
 (popup +all +defaults)
 (pretty-code +fira)
 vc-gutter
 vi-tilde-fringe
 window-select

 :editor
 (evil +everywhere +commands)
 snippets
 file-templates
 multiple-cursors
 rotate-text
 fold

 :emacs
 (dired +icons)
 electric
 vc

 :tools
 (lookup +docsets)
 eval
 make
 magit
 lsp
 editorconfig
 flyspell
 flycheck

 :lang
 (sh +fish)
 emacs-lisp
 markdown
 (csharp +unity)
 (haskell +lsp)
 (org
  +attach
  +babel
  +export
  +present)
 (cc +lsp)
 ocaml
 idris
 (web +html +css)
 (latex +latexmk)

 :term
 term
 eshell

 :app
 ;;(email +gmail)    ; emacs as an email client
 ;;(rss +org)        ; emacs as an RSS reader
 (write            ; emacs as a word processor (latex + org + markdown)
 +wordnut         ; wordnet (wn) search
 +langtool)       ; a proofreader (grammar/style check) for Emacs

 :collab
 ;;floobits          ; peer programming for a price
 ;;impatient-mode    ; show off code over HTTP

 :config
 (default)
 ;;literate
 )

Enable latex plugin in emacs-doom

Enable latex plugin in emacs-doom


(setq wakatime-packages '(wakatime-mode))

(defun wakatime/init-wakatime-mode ()
  (use-package wakatime-mode
    :defer t
    :init (add-hook 'prog-mode-hook 'wakatime-mode)))

(setq wakatime-packages '(wakatime-mode))

(defun wakatime/init-wakatime-mode ()
  (use-package wakatime-mode
    :defer t
    :init
    (add-hook 'prog-mode-hook 'wakatime-mode)
    :config
    (defun spacemacs/wakatime-dashboard ()
      (interactive)
      (browse-url "wakatime.com/dashboard"))
    (evil-leader/set-key
      "aW" 'spacemacs/wakatime-dashboard)))

Add config phase to Wakatime

Add config phase to Wakatime

This Adds the `spacemacs/wakatime-dashboard` function which opens the
dashboard in the browser.


This buffer is for notes you don't want to save, and for Lisp evaluation.
If you want to create a file, visit that file with C-x C-f,
then enter the text in that file's own buffer.

Clean out elisp practise file.

Clean out elisp practise file.


;; -*- no-byte-compile: t; -*-
;;; ~/.doom.d/packages.el

;;; Examples:
;; (package! some-package)
;; (package! another-package :recipe (:fetcher github :repo "username/repo"))
;; (package! builtin-package :disable t)
(package! cider
  :recipe (:fetcher github
           :repo "clojure-emacs/cider"
           :commit "200c88adb1314b5811ba749af42ffb6817c1ca1b"
           :files ("*.el" (:exclude ".dir-locals.el"))
           :old-names (nrepl)))
(package! clj-refactor
  :recipe (:fetcher github
           :repo "clojure-emacs/clj-refactor.el"
           :commit "3d5d1fbf28bfcc00f917cd96d6784968dcbbc962"))
(package! flymd)
(package! lispyville)
(package! sort-words)
(package! uuidgen)
(package! xterm-color)

;; -*- no-byte-compile: t; -*-
;;; ~/.doom.d/packages.el

;;; Examples:
;; (package! some-package)
;; (package! another-package :recipe (:fetcher github :repo "username/repo"))
;; (package! builtin-package :disable t)
(package! flymd)
(package! lispyville)
(package! sort-words)
(package! uuidgen)
(package! xterm-color)

Remove cider and clj-refactor pins

doom-emacs: Remove cider and clj-refactor pins


;;; tools/deft/config.el -*- lexical-binding: t; -*-

(def-package! deft
  :commands deft
  :init
  (setq deft-extensions '("org" "md" "tex" "txt")
        deft-default-extension "org"
        ;; de-couples filename and note title:
        deft-use-filename-as-title nil
        deft-use-filter-string-for-filename t
        deft-org-mode-title-prefix t
        ;; converts the filter string into a readable file-name using kebab-case:
        deft-file-naming-rules
              '((noslash . "-")
                (nospace . "-")
                (case-fn . downcase)))
  :config
  ;; start filtering immediately
  (add-hook! 'deft-mode-hook '((evil-insert-state nil)))
  (map! :map deft-mode-map
        :localleader
        :n "RET" #'deft-new-file-named
        :n "a" #'deft-archive-file
        :n "c" #'deft-filter-clear
        :n "d" #'deft-delete-file
        :n "f" #'deft-find-file
        :n "g" #'deft-refresh
        :n "l" #'deft-filter
        :n "n" #'deft-new-file
        :n "r" #'deft-rename-file
        :n "s" #'deft-toggle-sort-method
        :n "t" #'deft-toggle-incremental-search))

;;; tools/deft/config.el -*- lexical-binding: t; -*-

(def-package! deft
  :commands deft
  :init
  (setq deft-extensions '("org" "md" "tex" "txt")
        deft-default-extension "org"
        ;; de-couples filename and note title:
        deft-use-filename-as-title nil
        deft-use-filter-string-for-filename t
        deft-org-mode-title-prefix t
        ;; converts the filter string into a readable file-name using kebab-case:
        deft-file-naming-rules
              '((noslash . "-")
                (nospace . "-")
                (case-fn . downcase)))
  :config
  ;; start filtering immediately
  (set-evil-initial-state! 'deft-mode 'insert)
  (map! :map deft-mode-map
        :localleader
        :n "RET" #'deft-new-file-named
        :n "a" #'deft-archive-file
        :n "c" #'deft-filter-clear
        :n "d" #'deft-delete-file
        :n "f" #'deft-find-file
        :n "g" #'deft-refresh
        :n "l" #'deft-filter
        :n "n" #'deft-new-file
        :n "r" #'deft-rename-file
        :n "s" #'deft-toggle-sort-method
        :n "t" #'deft-toggle-incremental-search))

Use set-evil-initial-state! instead of a hook


(require 'multiple-cursors)

(smartrep-define-key global-map "C-l v" '(("n" . 'mc/mark-next-lines)
                                          ("p" . 'mc/mark-previous-lines)
                                          (">" . 'mc/mark-next-like-this)
                                          ("<" . 'mc/mark-previous-like-this)))

(smartrep-define-key global-map "C-l C-v" '(("C-n" . 'mc/mark-next-lines)
                                            ("C-p" . 'mc/mark-previous-lines)
                                            ("C->" . 'mc/mark-next-like-this)
                                            ("C-<" . 'mc/mark-previous-like-this)))

(mapc (lambda (cmd)
        (add-to-list 'mc/cmds-to-run-for-all cmd))
      '(
        sp--self-insert-command
        ))

(mapc (lambda (cmd)
        (add-to-list 'mc/cmds-to-run-once cmd))
      '(
        god-mode
        god-mode-all
        god-local-mode
        helm-confirm-and-exit-minibuffer
        split-window-horizontally
        split-window-vertically
        mc/mark-next-lines
        mc/mark-next-like-this
        undo-tree-visualizer-quit
        keyboard-escape-quit
        ))

(require 'multiple-cursors)

(smartrep-define-key global-map "C-l v" '(("n" . 'mc/mark-next-lines)
                                          ("p" . 'mc/mark-previous-lines)
                                          (">" . 'mc/mark-next-like-this)
                                          ("<" . 'mc/mark-previous-like-this)))

(smartrep-define-key global-map "C-l C-v" '(("C-n" . 'mc/mark-next-lines)
                                            ("C-p" . 'mc/mark-previous-lines)
                                            ("C->" . 'mc/mark-next-like-this)
                                            ("C-<" . 'mc/mark-previous-like-this)))

(mapc (lambda (cmd)
        (add-to-list 'mc/cmds-to-run-for-all cmd))
      '(
        sp--self-insert-command
        god-mode-self-insert
        ))

(mapc (lambda (cmd)
        (add-to-list 'mc/cmds-to-run-once cmd))
      '(
        god-mode
        god-mode-all
        god-local-mode
        helm-confirm-and-exit-minibuffer
        split-window-horizontally
        split-window-vertically
        mc/mark-next-lines
        mc/mark-next-like-this
        undo-tree-visualizer-quit
        undo-tree-visualize
        keyboard-escape-quit
        ))

Add some functions to the multiple cursors lists


;;; setup-help.el --- Help enhancements.
;;; Commentary:
;;; Code:

;; I use `describe-face' quite often, I'd really like a key for it
(define-key help-map (kbd "C-f") nil)
(define-key help-map (kbd "C-f") #'counsel-describe-face)

;; Command-log is useful sometimes, but let's not autoinstall as it
;; will only slow first run time.
(use-package command-log-mode
  :defer t)

;; which-key seems like a really nice help
(use-package which-key
  :ensure t
  :config
  (which-key-mode)
  :demand
  :diminish which-key-mode)

(provide 'setup-help)
;;; setup-help.el ends here

;;; setup-help.el --- Help enhancements.
;;; Commentary:
;;; Code:

;; I use `describe-face' quite often, I'd really like a key for it
(define-key help-map (kbd "C-f") nil)
(define-key help-map (kbd "C-f") #'counsel-describe-face)

;; Move help to leader rather than C-h
(evil-leader/set-key "h"
  help-map)

;; Command-log is useful sometimes, but let's not autoinstall as it
;; will only slow first run time.
(use-package command-log-mode
  :defer t)

;; which-key seems like a really nice help
(use-package which-key
  :ensure t
  :config
  (which-key-mode)
  :demand
  :diminish which-key-mode)

(provide 'setup-help)
;;; setup-help.el ends here

Move help-map to SPC h instead of C-h

Move help-map to SPC h instead of C-h


;; Set some variables based on environment
;; Are we on a mac?
(setq is-mac (equal system-type 'darwin))

;; Turn off mouse interface early in startup to avoid momentary display
;;;; Do show menu bar (running as cocoa app)
;;;; TODO turn of menu bar when running emacs from terminal
;;(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))

;; No splash screen
(setq inhibit-startup-message t)

;; Set up load path
(add-to-list 'load-path (expand-file-name "conf" user-emacs-directory))

(require '_packages)
(require '_global)
(require '_appearance)
(require '_key_bindings)

(require 'theme-park-mode)

;; Functions (load all files in defuns-dir)
(setq defuns-dir (expand-file-name "defuns" user-emacs-directory))
(dolist (file (directory-files defuns-dir t "\\w+"))
  (when (file-regular-p file)
    (load file)))

(when is-mac (require '_mac))

;; Set some variables based on environment
;; Are we on a mac?
(setq is-mac (equal system-type 'darwin))

;; Turn off mouse interface early in startup to avoid momentary display
;;;; Do show menu bar (running as cocoa app)
;;;; TODO turn of menu bar when running emacs from terminal
;;(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))

;; No splash screen
(setq inhibit-startup-message t)

;; Set up load path
(setq loadpath-mine (expand-file-name "conf" user-emacs-directory))
(add-to-list 'load-path loadpath-mine)

(require '_packages)
(require '_global)
(require '_appearance)
(require '_key_bindings)

(require 'theme-park-mode)

;; Functions (load all files in defuns-dir)
(setq defuns-dir (expand-file-name "defuns" user-emacs-directory))
(dolist (file (directory-files defuns-dir t "\\w+"))
  (when (file-regular-p file)
    (load file)))

(when is-mac (require '_mac))

Use var for load path

Use var for load path


(defconst mfa-dired-packages '(dired-narrow))

(defun mfa-dired/init-dired-narrow ()
  (use-package dired-narrow
    :defer t
    :init
    (spacemacs/set-leader-keys-for-major-mode 'dired-mode "/" #'dired-narrow)))

(defconst mfa-dired-packages '(dired-narrow dired))

(defun mfa-dired/init-dired-narrow ()
  (use-package dired-narrow
    :defer t
    :init
    (spacemacs/set-leader-keys-for-major-mode 'dired-mode "/" #'dired-narrow)))

(defun mfa-dired/post-init-dired ()
  (spacemacs|use-package-add-hook dired
    :post-config
    (evil-define-key 'evilified dired-mode-map
      "-" #'dired-up-directory)))

Remove vinegar key binding for directory up to avoid dired buffer being killed


((nil . ((projectile-project-compilation-cmd "npm --no-color --no-progress --no-spin install")
         (projectile-project-test-cmd        "node bin/jasmine --no-color")
         (projectile-project-run-cmd         "node bin/server.js"))))

((nil . ((pjones-project-compile-cmd "npm --no-color --no-progress --no-spin install")
         (pjones-project-test-cmd    "node bin/jasmine --no-color")
         (pjones-project-run-cmd     "node bin/server.js"))))

Change how Emacs runs various commands for this repo


;;; Uncomment the modules you'd like to use and restart Prelude afterwards

(require 'prelude-ido) ;; Super charges Emacs completion for C-x C-f and more
;; (require 'prelude-helm) ;; Interface for narrowing and search
(require 'prelude-company)

(require 'prelude-c)
;; (require 'prelude-clojure)
;; (require 'prelude-coffee)
;; (require 'prelude-common-lisp)
;; (require 'prelude-css)
(require 'prelude-emacs-lisp)
(require 'prelude-erc) ;; Emacs IRC client
;; (require 'prelude-erlang)
;; (require 'prelude-haskell)
(require 'prelude-js)
;; (require 'prelude-key-chord) ;; Binds useful features to key combinations
;; (require 'prelude-latex)
(require 'prelude-lisp)
;; (require 'prelude-mediawiki)
(require 'prelude-org) ;; Org-mode helps you keep TODO lists, notes and more
(require 'prelude-perl)
;; (require 'prelude-python)
;; (require 'prelude-ruby)
;; (require 'prelude-scala)
(require 'prelude-scheme)
(require 'prelude-shell)
;; (require 'prelude-evil)
;; (require 'prelude-scss)
;; (require 'prelude-web) ;; Emacs mode for web templates
(require 'prelude-xml)

;;; Uncomment the modules you'd like to use and restart Prelude afterwards

;; Emacs IRC client
(require 'prelude-erc)
(require 'prelude-ido) ;; Super charges Emacs completion for C-x C-f and more
;; (require 'prelude-helm) ;; Interface for narrowing and search
(require 'prelude-company)
;; (require 'prelude-key-chord) ;; Binds useful features to key combinations
;; (require 'prelude-mediawiki)
;; (require 'prelude-evil)

;;; Programming languages support
(require 'prelude-c)
;; (require 'prelude-clojure)
;; (require 'prelude-coffee)
;; (require 'prelude-common-lisp)
;; (require 'prelude-css)
(require 'prelude-emacs-lisp)
;; (require 'prelude-erlang)
;; (require 'prelude-haskell)
(require 'prelude-js)
;; (require 'prelude-latex)
(require 'prelude-lisp)
(require 'prelude-org) ;; Org-mode helps you keep TODO lists, notes and more
(require 'prelude-perl)
;; (require 'prelude-python)
;; (require 'prelude-ruby)
;; (require 'prelude-scala)
(require 'prelude-scheme)
(require 'prelude-shell)
;; (require 'prelude-scss)
;; (require 'prelude-web) ;; Emacs mode for web templates
(require 'prelude-xml)

Reorder a bit default module config

Reorder a bit default module config


(load-theme 'spacemacs-dark)
(face-spec-set 'hl-line '((t (:background "color-236" :inherit nil))))

;; (xterm-mouse-mode)

(load-theme 'spacemacs-dark)
(set-face-background 'lazy-highlight "#29422d")
(face-spec-set 'hl-line '((t (:background "color-236" :inherit nil))))

;; (xterm-mouse-mode)

Fix for spacemacs dark theme on terminals


;;; init-org.el --- inits Emacs for Org-mode and writing
;;
;; This orgfile is sourced instead of init.el for instances of Emacs dedicated for
;; writing fiction, papers, or simply org-mode. I prefer to keep this functionality
;; separate from stock Emacs.
;;
;;;

(defconst EMACS-WRITE t)

(defconst narf-theme 'narf-light-theme)
(defconst narf-default-font (font-spec :family "Hack" :size 14))
(defconst narf-writing-font (font-spec :family "Deja Sans" :size 14))
(set-frame-font narf-default-font)

(let (file-name-handler-alist
      (gc-cons-threshold 169715200))
  (tool-bar-mode   -1)  ; no toolbar

  (load (concat user-emacs-directory "init-load-path.el"))
  (load-theme narf-theme t)

  (mapc 'require
        `(core ; core/core.el

          core-popup           ; taming stray windows
          core-ui              ; draw me like one of your French editors
          core-evil            ; come to the dark side, we have cookies
          core-editor          ; filling the editor-shaped hole in the emacs OS
          core-company         ; for the lazy typist
          core-yasnippet       ; for the lazier typist
          core-auto-insert     ; for the laziest typist
          core-flycheck        ; remember that semicolon you forgot?
          core-project         ; whose project am I in?
          core-vcs             ; version control is a programmer's best friend
          core-helm            ; a search engine for life and love
          core-eval            ; run code, run.
          core-workgroups      ; cure Emacs alzheimers

          ;;; Environments
          module-markdown
          module-org
          module-plantuml

          ;;; Specific custom functionality
          ;; lib-demo
          ;; lib-writing
          ;; lib-tmux
          ;; lib-crm
          ;; lib-sonicpi

          ;;; Key bindings & ex commands
          my-bindings
          my-commands
          ))
  (narf-init))

(setq wg-session-file (expand-file-name "wg-org-default" narf-temp-dir))

Add basic alternative init file

Add basic alternative init file


;; DESCRIPTION:
;;   Useful patterns for using the ido menu with Javascript files.
;;
;; AUTHOR:
;;   Geoffrey Grosenbach http://peepcode.com
;;
;; Matches things like:
;;
;;   function bacon() {}        // Standard function
;;   getJSON: function () {}    // Function as a key in a hash
;;   this.post = function () {} // Instance method in a function
;;
;; USAGE:
;;   (require 'topfunky-js)

(setq topfunky-js-imenu-generic-expression
      '(("Named Function" "function\\s-+\\(\\w+\\)\\s-*(" 1)
        ("Hash Method"  "^\\s-*\\(\\w+\\): function (" 1)
        ("Instance Method" "this\.\\(\\w+\\) = function (" 1)
        ))

(add-hook 'javascript-mode-hook
          (lambda ()
            (setq imenu-generic-expression topfunky-js-imenu-generic-expression)))

(provide 'topfunky-js)

;; DESCRIPTION:
;;   Useful patterns for using the ido menu with Javascript files.
;;
;; AUTHOR:
;;   Geoffrey Grosenbach http://peepcode.com
;;
;; Matches things like:
;;
;;   function bacon() {}        // Standard function
;;   getJSON: function () {}    // Function as a key in a hash
;;   this.post = function () {} // Instance method in a function
;;
;; USAGE:
;;   (require 'topfunky-js)

(setq topfunky-js-imenu-generic-expression
      '(("Named Function" "function\\s-+\\(\\w+\\)\\s-*(" 1)
        ("Hash Method"  "^\\s-*\\(\\w+\\):\\s-*function\\s-*(" 1)
        ("Instance Method" "this\.\\(\\w+\\)\\s-*=\\s-*function\\s-*(" 1)
        ))

(add-hook 'javascript-mode-hook
          (lambda ()
            (setq imenu-generic-expression topfunky-js-imenu-generic-expression)))

(provide 'topfunky-js)

Make JS function pattern more lenient instead of expecting Crockford style.


;;; editor/open-containing-dir/config.el -*- lexical-binding: t; -*-

(defvar external-file-manager "xdg-open"
  "Process that should be called to open an external file manager.")

(defun open-containing-dir ()
  "Open the containing directory of the current buffer in a file manager.

Uses the executable `external-file-manager' to call an external file manager.
If the current mode is dired, opens the current directory and not its parent."
  (interactive)
  (let ((dir (cond
              ((not (buffer-file-name)) nil)
              ((eq major-mode 'dired-mode) (buffer-file-name))
              (t (file-name-directory (buffer-file-name))))))
    (when dir
      (start-process "external-file-manager"
                     "*external-file-manager*"
                     external-file-manager dir))))

(map! :leader "f d" #'open-containing-dir)

Allow opening external file manager

[emacs] Allow opening external file manager


;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((emacs-lisp-mode
  (bug-reference-url-format . "https://github.com/clojure-emacs/sayid/issues/%s")
  (bug-reference-bug-regexp . "#\\(?2:[[:digit:]]+\\)")
  (indent-tabs-mode . nil)
  (fill-column . 80)
  (sentence-end-double-space . t)
  (emacs-lisp-docstring-fill-column . 75)
  (checkdoc-symbol-words . ("top-level" "major-mode" "macroexpand-all" "print-level" "print-length"))
  (checkdoc-package-keywords-flag)
  (checkdoc-arguments-in-order-flag)
  (checkdoc-verb-check-experimental-flag)
  (elisp-lint-indent-specs . ((if-let* . 2)
                              (when-let* . 1)
                              (let* . defun)
                              (nrepl-dbind-response . 2)
                              (cider-save-marker . 1)
                              (cider-propertize-region . 1)
                              (cider-map-repls . 1)
                              (cider--jack-in . 1)
                              (cider--make-result-overlay . 1)
                              ;; need better solution for indenting cl-flet bindings
                              (multiline-comment-handler . defun) ;; cl-flet
                              (insert-label . defun)              ;; cl-flet
                              (insert-align-label . defun)        ;; cl-flet
                              (insert-rect . defun)               ;; cl-flet
                              (cl-defun . 2)
                              (with-parsed-tramp-file-name . 2)
                              (thread-first . 1)
                              (thread-last . 1))))
 (clojure-mode
  (clojure-indent-style . :always-align)
  (indent-tabs-mode . nil)
  (fill-column . 80)))

;; To use the bug-reference stuff, do:
;;     (add-hook 'text-mode-hook #'bug-reference-mode)
;;     (add-hook 'prog-mode-hook #'bug-reference-prog-mode)

Set some common defaults for emacs-lisp-mode and clojure-mode

This should ensure the code style stays consistent (at least when the
contributors are using Emacs).


;;; hare-tests.el ---

;; Copyright (c) 2015 Gracjan Polak. All rights reserved.

;; This file 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, or (at your option)
;; any later version.

;; This file 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/>.

;;; Code:

(require 'ert)
(require 'hare)

(ert-deftest loading-test ())

(provide 'hare-tests)

Add first (empty) test case for elisp code


;;; femacs-osx.el --- OS X Specific configuration
;;
;; Copyright © 2016 Anurag Mishra
;;
;; Author: Anurag Mishra
;; URL: https://github.com/anuragm/emacs-fast
;; Version: 1.0.0
;; Keywords: convenience

;; This file is not part of GNU Emacs.

;;; Commentary:

;; Configures OS X.

;;; License:

;; Copyright (c) 2016 Anurag Mishra

;; Permission is hereby granted, free of charge, to any person obtaining a copy
;; of this software and associated documentation files (the "Software"), to deal
;; in the Software without restriction, including without limitation the rights
;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;; copies of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:
;;
;; The above copyright notice and this permission notice shall be included in all
;; copies or substantial portions of the Software.
;;
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;; SOFTWARE.

;;; Code:

;; Don't delete directly, use Trash
(setq delete-by-moving-to-trash t)

;; Use system browser
(setq browse-url-browser-function 'browse-url-default-macosx-browser)

;; Some helper functions.
(use-package dired-x
  :ensure nil)

(defun finder-here ()
  "Opens current buffer's directory in Finder."
  (interactive)
  (dired-smart-shell-command "open \"$PWD\"" nil nil))

(defun iterm-here ()
  "Opens current buffer's directory in iTerm."
  (interactive)
  (dired-smart-shell-command "open -a iTerm2 \"$PWD\"" nil nil))

;; Use gls for dired mode if installed.
(when (executable-find "gls")
  (setq insert-directory-program (executable-find "gls")))

(provide 'femacs-osx)
;;; femacs-osx.el ends here

Add OS X specific changes

Add OS X specific changes


;; Add paths (not required if EXWM is installed from GNU ELPA)
(add-to-list 'load-path "~/.emacs.d/elpa/xelb-0.6/")
(add-to-list 'load-path "~/.emacs.d/elpa/exwm-0.4/")
(add-to-list 'load-path "~/.emacs.d/elpa/cl-generic-0.2/")

;; Load EXWM
(require 'exwm)
(require 'exwm-config)
(exwm-config-default)

Add a new file for exwm customisations

Add a new file for exwm customisations

Emacs X Windows Manager


(use-package paredit
  :init
  (progn
    (add-hook 'emacs-lisp-mode-hook 'paredit-mode)
    (add-hook 'eval-expression-minibuffer-setup-hook 'paredit-mode)
    (add-hook 'ielm-mode-hook 'paredit-mode)
    (add-hook 'lisp-mode-hook 'paredit-mode)
    (add-hook 'lisp-interaction-mode-hook 'paredit-mode)
    (add-hook 'scheme-mode-hook 'paredit-mode)))

Enable paredit-mode for lisp-like modes.


;; This file is automatically generated by the multiple-cursors extension.
;; It keeps track of your preferences for running commands with multiple cursors.

(setq mc/cmds-to-run-for-all
      '(
        ng/C-k
        ng/C-w
        ng/end
        ng/home
        ))

(setq mc/cmds-to-run-once
      '(
        ))

Add multiple cursor run-once run-all file


;;; Directory Local Variables
;;; See Info node `(emacs) Directory Variables' for more information.

((nil
  (tab-width . 2)
  (c-file-style . "swift")
  (eval .
        (unless (featurep 'swift-mode)
          (load-library
           (concat
            (let ((dlff (dir-locals-find-file default-directory)))
              (if (listp dlff) (car dlff) (file-name-directory dlff)))
            "utils/swift-mode")))))
 (c++mode
  (whitespace-style face lines indentation:space)
  (eval whitespace-mode))
 (swift-mode
  (tab-always-indent t)))

;; Local Variables:
;; eval: (whitespace-mode -1)
;; End:

Add project directory local variables for Emacs users

I've been carrying this file around in my working copy for months now;
it makes sure you have swift-mode loaded for .swift files and sets up
cc-mode for editing Swift's ObjC++ files in our project's style.

Swift SVN r10641


;;; femacs-python.el --- Support for Python programming
;;
;; Copyright © 2018 Anurag Mishra
;;
;; Author: Anurag Mishra
;; URL: https://github.com/anuragm/emacs-fast
;; Version: 1.0.0
;; Keywords: convenience

;; This file is not part of GNU Emacs.

;;; Commentary:

;; Adds support for Python programming language using auto completion, REPL, etc.

;;; License:

;; Copyright (c) 2018 Anurag Mishra

;; Permission is hereby granted, free of charge, to any person obtaining a copy
;; of this software and associated documentation files (the "Software"), to deal
;; in the Software without restriction, including without limitation the rights
;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
;; copies of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:
;;
;; The above copyright notice and this permission notice shall be included in all
;; copies or substantial portions of the Software.
;;
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;; SOFTWARE.

;;; Code:

(defun femacs/ein-mode-hook()
  "Custom setup for EIN mode."
  (setq-local fill-column 90)
  (auto-fill-mode)
  (whitespace-mode))

;; Add iPython support
;; Ensure that iPython and Jupyter binaries are in Emacs path.
(use-package ein
  :ensure t
  :diminish ein:notebook-mode
  :init
  (setq ein:completion-backend 'ein:use-company-backend)
  (add-hook 'ein:notebook-multilang-mode-hook #'femacs/ein-mode-hook)
  :commands
  (ein:jupyter-server-start ein:notebooklist-login))

(defun femacs/python-mode-hook()
  "Custom bindings for python mode."
  (setq-local fill-column 90)
  (nlinum-mode)
  (auto-fill-mode)
  (company-mode)
  (whitespace-mode)
  (dtrt-indent-mode))

(add-hook 'python-mode-hook #'femacs/python-mode-hook)

(provide 'femacs-python)
;;; femacs-python.el ends here

Add support for Python and Jupyter

Add support for Python and Jupyter


;;; elfeed-link.el --- misc functions for elfeed -*- lexical-binding: t; -*-

;; This is free and unencumbered software released into the public domain.

;;; Commentary:

;; Code for integration with org-mode.

;; To use, add (require 'elfeed-link) somewhere in your configuration.

;;; Code:

(require 'elfeed-db)
(require 'elfeed-show)
(require 'elfeed-search)

(require 'org)

(defun elfeed-link-store-link ()
  "Store a link to an elfeed search or entry buffer.

When storing a link to an entry, automatically extract all the
entry metadata.  These can be used in the capture templates as
%:elfeed-entry-<prop>.  See `elfeed-entry--create' for the list
of available props."
  (cond ((derived-mode-p 'elfeed-search-mode)
         (org-store-link-props
          :type "elfeed"
          :link (format "elfeed:%s" elfeed-search-filter)
          :description elfeed-search-filter))
        ((derived-mode-p 'elfeed-show-mode)
         (apply
          'org-store-link-props
          :type "elfeed"
          :link (format "elfeed:%s#%s"
                        (car (elfeed-entry-id elfeed-show-entry))
                        (cdr (elfeed-entry-id elfeed-show-entry)))
          :description (elfeed-entry-title elfeed-show-entry)
           (cl-loop for (prop) in (cdr (plist-get
                                        (symbol-plist 'elfeed-entry)
                                        'cl-struct-slots))
                    nconc (list
                           (intern (concat ":elfeed-entry-" (symbol-name prop)))
                           (funcall
                            (intern (concat "elfeed-entry-" (symbol-name prop)))
                            elfeed-show-entry)))))))

(defun elfeed-link-open (filter-or-id)
  "Jump to an elfeed entry or search.

Depending on what FILTER-OR-ID looks like, we jump to either
search buffer or show a concrete entry."
  (if (string-match "\\([^#]+\\)#\\(.+\\)" filter-or-id)
      (elfeed-show-entry (elfeed-db-get-entry
                          (cons (match-string 1 filter-or-id)
                                (match-string 2 filter-or-id))))
    (switch-to-buffer (elfeed-search-buffer))
    (unless (eq major-mode 'elfeed-search-mode)
      (elfeed-search-mode))
    (elfeed-search-set-filter filter-or-id)))

;;;###autoload
(eval-after-load 'org
  '(if (version< (org-version) "9.0")
       (progn
         (org-add-link-type "elfeed" #'elfeed-link-open)
         (add-hook 'org-store-link-functions #'elfeed-link-store-link))
     (org-link-set-parameters
      "elfeed"
      :follow #'elfeed-link-open
      :store #'elfeed-link-store-link)))

(provide 'elfeed-link)

;;; elfeed-link.el ends here

Add support for org links.

Add support for org links.


;; -*-no-byte-compile: t; -*-

(defun connect-is(host port)
  (interactive "sHost: \nnPort: ")
  (telnet host port)
  (let* ((buf (current-buffer))
	 (state :start)
	 (proc (get-buffer-process buf)))
    (when proc
      (telnet-simple-send proc "TELNET"))
    ;;search for CL-USER(2) before sending data
    (while (not (eq state :done))
      (cond ((and (search-backward "CL-USER(2):" (line-beginning-position) t)
		  (eq state :start))
	     (setq state :end)
	     (telnet-simple-send proc "(ignore-errors (let ((file (system:make-temp-file-name))) (when (excl:new-start-emacs-lisp-interface :port nil :announce-to-file file) (loop (when (probe-file file) (return))) (let ((in (open file :if-does-not-exist nil))) (when in (loop for line = (read-line in nil) while line do (format t  \"~a~%\" line)) (close in))) (delete-file file))))"))
	    ((search-backward "CL-USER(3):" (line-beginning-position) t)
	     (telnet-simple-send proc "(:exit-telnet)")
	     (setq state :done))
	    (t
	     (accept-process-output proc 0.5))))
    ;;Answer we look for is after CL-USER(2)
    (when (search-backward "CL-USER(2):" nil t)
      (forward-line 1)
      (let ((data (buffer-substring-no-properties (line-beginning-position) (line-end-position)))
	    (file (make-temp-file "isconnect")))
	(with-temp-buffer
	  ;;write data to a temp file and start emacs lisp interface
	  (insert data)
	  (write-region (point-min) (point-max) file)
	  (fi:start-interface-via-file host "*common-lisp*" file))
	(delete-file file)
	(kill-buffer buf)))))

Connect to a running IS

Connect to a running IS


(use-package tramp
  :init (setq tramp-ssh-controlmaster-options
              "-o ControlMaster=auto -o ControlPath='tramp.%%C' -o ControlPersist=no"))
(provide 'tramp-init)

Remove ox-wk as it seems broken. Add Tramp init as it is now needed for ssh changes.


(require 'google-translate)
(setq google-translate-enable-ido-completion t)
(setq google-translate-default-source-language "En")
(setq google-translate-default-target-language "Fr")

Add google translate init file

Add google translate init file


(defun personal-org-mode-defaults ()
  (setq org-alphabetical-lists t))

(add-hook 'org-mode-hook 'personal-org-mode-defaults)

(provide 'personal-org)

Allow alphabetical lists in org-mode

Allow alphabetical lists in org-mode


(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(require 'auto-complete-config)
(ac-config-default)

(define-key ac-mode-map (kbd "M-TAB") 'auto-complete)

(require 'auto-complete-config)
(ac-config-default)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")

(define-key ac-mode-map (kbd "M-TAB") 'auto-complete)

Fix order issue for AC setup

Fix order issue for AC setup


;;; Package --- Summary:

;;; Summary:

;;; Commentary:

;;; Code:
(defvar mocha-command "mocha")

(defvar mocha-environment-variables nil)

(defvar mocha-reporter "dot")

(defvar mocha-options nil)

(defvar mocha-project-test-directory nil)

(defun mocha-test-project ()
  "Test the current project."
  nil)

(defun mocha-test-file ()
  "Test the current file."
  nil)

(defun mocha-test-at-point ()
  "Test the current innermost 'it' or 'describe' or the file if none is found."
  nil)

(provide 'mocha)
;;; mocha.el ends here

Add file and spike out basic interface.

Add file and spike out basic interface.


;;; test-lib.el --- test library for runfiles test   -*- lexical-binding: t; -*-

;; Copyright 2021 Google LLC
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;;     https://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.

;;; Commentary:

;; Test library for //elisp/runfiles:runfiles_test.

;;; Code:

(provide 'elisp/runfiles/test-lib)
;;; test-lib.el ends here

Check in forgotten test data file

Check in forgotten test data file


;;; femacs-elisp.el --- Support for editing Emacs lisp files.
;;
;; Copyright © 2016 Anurag Mishra
;;
;; Author: Anurag Mishra
;; URL: https://github.com/anuragm/emacs-fast
;; Version: 1.0.0
;; Keywords: convenience

;; This file is not part of GNU Emacs.

;;; Commentary:

;; Adds useful modes and enables fly-check

;;; License:

;; Copyright (c) 2016 Anurag Mishra

;; 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 2 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/>.

;;; Code:

;; CAUTION : Set variables first before loading modes.
(add-hook
 'emacs-lisp-mode-hook
 '(lambda ()
    (unless (string= "*scratch*" (buffer-name))
      (setq-local fill-column 90)
      (setq-local whitespace-line-column 90)
      (auto-fill-mode)
      (flycheck-mode 1)
      (yas-minor-mode 1)
      (whitespace-mode)
      (nlinum-mode 1)
      (company-mode)
      (eldoc-mode))))

(provide 'femacs-elisp)
;;; femacs-elisp.el ends here

Add support for Emacs lisp mode

Add support for Emacs lisp mode


(defvar improviz-mode-hook nil)

;;;###autoload
(add-to-list 'auto-mode-alist '("\\.pz\\'" . improviz-mode))

(defun improviz-mode ()
  "Major mode for Improviz editing"
  (interactive)
  (general-nvmap
   :prefix ","
   "e" 'send-improviz-program
   ))

(defun send-improviz-program ()
  (interactive)
  (request
   "http://localhost:3000/read"
   :type "POST"
   :data (buffer-string)
   :parser 'json-read
   :success (function*
             (lambda ()
               (message "Sent program"))))
  )

(provide 'improviz)

Add basic emacs mode to use for sending stuff


;;; Directory Local Variables
;;; See Info node `(emacs) Directory Variables' for more information.

((emacs-lisp-mode
  (sentence-end-double-space . t)
  (eval flycheck-mode)
  (eval checkdoc-minor-mode)))

;; Local Variables:
;; mode: fundamental
;; End:

Configure some variables in emacs-lisp-mode


(require 'make-mode)

(define-key makefile-mode-map (kbd "M-n") #'highlight-symbol-next)
(define-key makefile-mode-map (kbd "M-p") #'highlight-symbol-next)

Use my usual highlight-symbol keybindings in Makefiles.


(defun wte--unique-filename (stub &optional index)
  (setq index (or index 1))
  (let ((filename (concat "~/projects/what-the-emacsd/posts/"
                          stub
                          ".el"
                          (if (< index 10) "-0" "-")
                          (number-to-string index)
                          ".html")))
    (if (file-exists-p filename)
        (wte--unique-filename stub (1+ index))
      filename)))

(defun what-the-emacsd-post (beg end)
  (interactive "r")
  (let ((example (with-current-buffer (htmlize-region beg end)
                    (search-forward "
")
                    (setq beg (point))
                    (search-forward "
")
                    (forward-char -7)
                    (buffer-substring beg (point))))
         (filename (wte--unique-filename (buffer-file-name-body))))
    (find-file filename)
    (insert (format "

%s

" example))
    (goto-char 4)))

(provide 'my-defuns)

Add defun to create new what-the-emacsd blogpost


;;; lang/latex/+latexmk.el -*- lexical-binding: t; -*-
;;;###if (featurep! +latexmk)

(def-package! auctex-latexmk
  :after-call (latex-mode-hook LaTeX-mode-hook)
  :init
  ;; Pass the -pdf flag when TeX-PDF-mode is active
  (setq auctex-latexmk-inherit-TeX-PDF-mode t)
  ;; Set LatexMk as the default
  (setq-hook! LaTeX-mode TeX-command-default "LatexMk")
  :config
  ;; Add latexmk as a TeX target
  (auctex-latexmk-setup))

Move latexmk setup into seperate file

Move latexmk setup into seperate file


;;; Backup files
(setq make-backup-files nil) ; stop creating backup~ files
(setq auto-save-default nil) ; stop creating #autosave# files

;;; Enable matching parenthesis
(show-paren-mode)

;;; Open all files in read-only mode
(add-hook 'find-file-hook
          '(lambda ()
             (when (and (buffer-file-name)
                        (file-exists-p (buffer-file-name))
                        (file-writable-p (buffer-file-name)))
               (message "Toggle to read-only for existing file")
               (toggle-read-only 1))))

;;; Keyboard bindings
(global-set-key (kbd "C-x %") 'split-window-horizontally)
(global-set-key (kbd "C-x \"") 'split-window-vertically)

Add customizations to start emacs in terminal mode


;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((cider-repl-mode
  (cider-refresh-before-fn . "comic-reader.system/stop"))
 (clojure-mode
  (cider-refresh-before-fn . "comic-reader.system/stop")))

Add emacs dir local variables for refreshing


(add-auto-mode 'haml-mode "\.haml$")
(add-auto-mode 'sass-mode "\.sass$")
(autoload 'haml-mode "haml-mode" "Mode for editing haml files" t)
(autoload 'sass-mode "sass-mode" "Mode for editing sass files" t)

(require 'flymake-haml)
(add-hook 'haml-mode-hook 'flymake-haml-load)
(add-hook 'sass-mode-hook 'flymake-sass-load)

(add-hook 'sass-mode-hook 'ac-css-keywords-setup)

(provide 'init-haml)

Add new init file for haml/sass

Add new init file for haml/sass


;;A simple Hive mode for emacs derived from SQL mode.

;;Define regex for various classes of hive keywords
(setq hive-constants '("null"))
(setq hive-constants-regex (regexp-opt hive-constants 'words))
(setq hive-constants nil)

(setq hive-datatypes '("tinyint" "smallint" "int" "bigint" "boolean" "float" "double" "string" "binary" "timestamp" "decimal" "varchar" "char" "array" "struct" "uniontype" "textfile" "sequencefile" "rcfile" "inputformat"))
(setq hive-datatypes-regex (regexp-opt hive-datatypes 'words))
(setq hive-datatypes nil)

(setq hive-keywords-ddl '("create" "database" "schema" "comment" "if" "not" "exists" "location" "drop" "restrict" "cascade" "alter" "set" "table" "external" "partitioned" "by" "clustered" "skewed" "row" "format" "delimited" "stored" "as" "like" "partition" "to" "replace" "view" "index" "on" "temporary" "function" "show" "tables" "describe" "partitions"))
(setq hive-keywords-dml '("add" "touch" "load" "data" "overwrite" "into" "insert" "select" "from" "where" "join" "semi" "left" "right" "outer" "union" "all" "group" "order" "is" "and" "or"))
(setq hive-allkeywords-regex (regexp-opt (append hive-keywords-ddl hive-keywords-dml) 'words ))
(setq hive-keywords-ddl nil)
(setq hive-keywords-dml nil)

;;Define font face for keywords
(setq hive-font-lock-keywords
      `(
	(,hive-constants-regex . font-lock-constant-face)
	(,hive-datatypes-regex . font-lock-type-face)
	(,hive-allkeywords-regex . font-lock-keyword-face)
))

;;Define Hive mode
(define-derived-mode hive-mode sql-mode
  "Hive mode"
  "Basic hive mode derived from SQL mode"

  (setq font-lock-defaults '((hive-font-lock-keywords)))

  (setq hive-constants-regex nil)
  (setq hive-datatypes-regex nil)
  (setq hive-allkeywords-regex nil)
)

(provide 'hive-mode)

Add hive mode to emacs

Add hive mode to emacs


(
 (c++-mode . ((fill-column . 80)
              (indent-tabs-mode . nil)))
 (c-mode . ((fill-column . 80)
            (indent-tabs-mode . nil)))
 (python-mode . ((fill-column . 80)
                 (tab-width . 2)
                 (indent-tabs-mode . nil)))
)

Subzero: Make life a little easier for emacs users.

Emacs will try to execute .dir-locals.el whenever loading a file under
the subzero directory.  It sets local variables depending on the mode.

Set the fill-column to 80 for c++-mode, c-mode, and python-mode.  The
main use is when using M-q to reformat multi-line comments.

Disable tabs (use spaces instead) in c++-mode, c-mode, and
python-mode.

Set the tab-width to 2 spaces in python-mode.  (The tab-width doesn't
really matter in c++-mode or c-mode thanks to clang-format.)

BUG= none
R=kschimpf@google.com

Review URL: https://codereview.chromium.org/1199133005


(use-package pkgbuild-mode
  :init
  (progn
    (add-to-list 'auto-mode-alist '("\\PKGBUILD$" . pkgbuild-mode))))

(provide 'setup_archlinux)

Switch to pkgbuild mode for PKGBUILD files.


(setq dw/open-url-map
  (let ((map (make-sparse-keymap)))
    (define-key map (kbd "<return>") 'ivy-immediate-done)
    map))

(defun dw/open-url ()
  (interactive)
  (let ((history-items
          (with-temp-buffer
            (insert-file-contents "~/.config/vimb/history")
            (split-string (buffer-string) "\n" t))))
    (ivy-read "Open URL: " (remove-duplicates history-items :test #'string-equal)
              :keymap dw/open-url-map
              :action (lambda (item)
                        (start-process "vimb" nil "vimb" (car (split-string item (string ?\t))))))))

emacs: Add initial attempt at a URL opener for Vimb with Ivy


;; Project-wide Emacs settings
(
 ;; `nil' settings apply to all language modes
 (nil
  ;; Use only spaces for indentation
  (indent-tabs-mode . nil))
 (c-mode
  ;; In C code, indentation is four spaces
  (c-basic-offset . 4)))

Add project-wide Emacs settings file

Add project-wide Emacs settings file

Add a .dir-locals.el file, which applies indentation-related settings
when editing any file in the project with Emacs.


;; -*- lexical-binding: t -*-

;; Auto-indent after paste in Go triggers goimports, that makes pasting imports
;; difficult. Let's let gofmt triggered by file save handle the indentation.
(add-to-list 'spacemacs-indent-sensitive-modes 'go-mode)

Make behavior of pasting into Go source files less annoying


;;  `rbdbg-track-mode' tracks shell output

(eval-when-compile
  (require 'cl)
  (setq load-path (cons nil load-path))
  (load "rbdbg-track")
  (setq load-path (cdr load-path)))

(defvar rbdbg-track-minor-mode nil
  "Non-nil if using rbdbgr-track mode as a minor mode of some other mode.
Use the command `rbdbg-minor-mode' to toggle or set this variable.")

(defvar rbdbg-track-minor-mode-map
  (let ((map (make-sparse-keymap)))
    (define-key map "\C-cg"	      'rbdbg-goto-loc)
    map)
  "Keymap for rbdbgr-track minor mode.")

(define-minor-mode rbdbgr-track-mode
  "Minor mode for tracking ruby debugging inside a process shell."
  :init-value nil
  :lighter " rbdbgr"   ;; indicator in the mode line.
  ;; The minor mode bindings.
  :global nil
  :group 'rbdbg
  :keymap rbdbg-track-minor-mode-map
  (add-hook 'comint-output-filter-functions
	    'rbdbg-track-comint-output-filter-hook)
  (add-hook 'eshell-output-filter-functions
	    'rbdbg-track-eshell-output-filter-hook)
  ;; (run-mode-hooks 'rdebug-track-mode-hook)
;; FIXME: add buffer local variables (in the process buffer) for:
;; rbdbg-last-output-start
)

Support eshell as well as shell. Break out track mode into a separate file.


;;; Directory Local Variables
;;; See Info node `(emacs) Directory Variables' for more information.

((java-mode
  (c-basic-offset . 2)
  (indent-tabs-mode . nil)))
  ))

Set the indent style for Emacs users.

Set the indent style for Emacs users.

Signed-off-by: Benoit Sigoure <d0ba46810740e35622837d76cd77ceb8c4bf46f5@gmail.com>


(require 'json)

(setq path-seperator '"/")
(setq settings-file-name '"settings.json")

;;(json-read-file '"../../settings.json")

;; function to find the path to the next (upwards in the directory tree)
;; settings file.
(defun load-next-settings-file ()
;;(interactive)
(setq cur-dir (buffer-file-name))

;;(message cur-dir)

(setq idx-sep  (length cur-dir))
;;(message (number-to-string cur-pos))
(setq b-stop-looping nil)
(while (and (> idx-sep 0) (not b-stop-looping))
  ;; find the last path seperator in the path string
  (setq idx-sep 0)
  (setq read-pos 0)

  (while (< read-pos (- (length cur-dir) 1))
    (if (string= (substring cur-dir read-pos (+ read-pos 1)) path-seperator)
	;(message "bang")
	(setq idx-sep read-pos)
;;      (message (number-to-string idx-sep))
      )

    (setq read-pos (1+ read-pos))
    ;(message (number-to-string read-pos))
    )

  ;;(message (concat "/ at " (number-to-string idx-sep)))
  ;;  (message cur-dir)
;;  (message (number-to-string idx-sep))
  (setq cur-pos idx-sep);; (length cur-dir))
  (setq cur-dir (substring cur-dir 0 (1+ idx-sep)))
  ;;(message cur-dir)
;;  (message "bla")
  ;;  (setq last-sep '(search-backward
  ;;(print cur-pos)
  ;;  (message cur-pos)
  ;;  (setq cur-dir '(substring cur-dir 1 2))
;;  (message (number-to-string idx-sep))
  ;;(setq cur-pos (- cur-pos 1))
(setq candidate-path (concat cur-dir settings-file-name))
  (if (file-exists-p candidate-path)

(setq settings (json-read-file candidate-path))
;;(message "bla")
;;(message candidate-path)
;;(message "bla")
;;(setq b-stop-looping t)

;;(message candidate-path)
;;(message candidate-path)
;;(message "bla")
;;(message "bla")

;;(message (file-exists-p candidate-path))
)
)
)

(defun print-alist (list)
;;(setq settings)
(while list
  (setq cur-element (car list))
  (setq cur-key (car cur-element))
  (setq cur-value (cdr cur-element))
  (message (format "%10s: %s" cur-key cur-value))
  (setq list (cdr list))
)
)

;;(setq settings ())
(load-next-settings-file)
;;(message (load-next-settings-file))
;;(message settings)

;;(print-alist settings)
(print-alist settings)

(print-alist (cons (assoc 'name settings) '()))

Add first working Elisp version.

Add first working Elisp version.


(defvar echo-server-port 9000
  "port of the echo server")

(defvar echo-server-clients '()
  "alist where KEY is a client process and VALUE is the string")

(defun echo-server-start nil
  "starts an emacs echo server"
  (interactive)
  (unless (process-status "echo-server")
    (make-network-process :name "echo-server" :buffer "*echo-server*"
                          :family 'ipv4 :service echo-server-port
                          :sentinel 'echo-server-sentinel
                          :filter 'echo-server-filter :server 't)
    (setq echo-server-clients '())
    )
  )

(defun echo-server-stop nil
  "stop an emacs echo server"
  (interactive)
  (while  echo-server-clients
    (delete-process (car (car echo-server-clients)))
    (setq echo-server-clients (cdr echo-server-clients)))
  (delete-process "echo-server")
  )

(defun echo-server-filter (proc string)
  (let ((pending (assoc proc echo-server-clients))
        message
        index)
    ;;create entry if required
    (unless pending
      (setq echo-server-clients (cons (cons proc "") echo-server-clients))
      (setq pending  (assoc proc echo-server-clients)))
    (setq message (concat (cdr pending) string))
    (while (setq index (string-match "\n" message))
      (setq index (1+ index))
      (process-send-string proc (substring message 0 index))
      (echo-server-log  (substring message 0 index) proc)
      (setq message (substring message index)))
    (setcdr pending message))
  )

(defun echo-server-sentinel (proc msg)
  (when (string= msg "connection broken by remote peer\n")
    (setq echo-server-clients (assq-delete-all proc echo-server-clients))
    (echo-server-log (format "client %s has quit" proc))))

;;from server.el
(defun echo-server-log (string &optional client)
  "If a *echo-server* buffer exists, write STRING to it for logging purposes."
  (if (get-buffer "*echo-server*")
      (with-current-buffer "*echo-server*"
        (goto-char (point-max))
        (insert (current-time-string)
                (if client (format " %s:" client) " ")
                string)
        (or (bolp) (newline)))))
(provide 'echo-server)

Add echo server in elisp (needs work)

Add echo server in elisp (needs work)


;;; lang/latex/+preview-pane.el -*- lexical-binding: t; -*-
;;;###if (featurep! +preview-pane)

(def-package! latex-preview-pane
  :when (featurep! +preview-pane)
  :hook ((latex-mode LaTeX-mode) . latex-preview-pane-enable)
  :commands latex-preview-pane-mode
  :init
  (setq latex-preview-pane-multifile-mode 'auctex)
  :config
  (add-to-list 'TeX-view-program-list '("preview-pane" latex-preview-pane-mode))
  (add-to-list 'TeX-view-program-selection '(output-pdf "preview-pane"))
  (define-key! doc-view-mode-map
    (kbd "ESC") #'delete-window
    "q" #'delete-window
    "k" (λ! (quit-window) (delete-window))))

Move preview-pane setup into seperate file


;;; lang/latex/+viewers.el -*- lexical-binding: t; -*-

(when (featurep! +okular)
  ;; Configure Okular as viewer. Including a bug fix
  ;; (https://bugs.kde.org/show_bug.cgi?id=373855)
  (add-to-list 'TeX-view-program-list '("Okular" ("okular --unique file:%o" (mode-io-correlate "#src:%n%a"))))
  (add-to-list 'TeX-view-program-selection '(output-pdf "Okular")))

;; Or Skim
(when (featurep! +skim)
  (add-to-list 'TeX-view-program-selection 'output-pdf '("Skim")))

;; Or Zathura
(when (featurep! +zathura)
  (add-to-list 'TeX-view-program-selection '(output-pdf "Zathura")))

;; Or PDF-tools, but only if the module is also loaded
(when (and (featurep! :tools pdf)
           (featurep! +pdf-tools))
  (add-to-list 'TeX-view-program-selection '(output-pdf "PDF Tools"))
  ;; Enable auto reverting the PDF document with PDF Tools
  (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer))

Move viewer setup into different file

Move viewer setup into different file


(defun my/cleanup-buffer ()
  (interactive)
  (delete-trailing-whitespace)
  (untabify (point-min) (point-max))
  (indent-region (point-min) (point-max)))

(global-set-key (kbd "C-c n") 'my/cleanup-buffer)
(global-set-key (kbd "C-c C-n") 'my/cleanup-buffer)

Add global binding for buffer cleanup.

Add global binding for buffer cleanup.


(set-face-foreground 'mode-line "black")
(set-face-background 'mode-line "purple")
(set-face-background 'mode-line-inactive "blue")
(set-face-background 'modeline-inactive "red")

Add color theme config file with entries for mode bar


;;; Useful helpers for lisp programming

(defun ds/buffer-context (start end n)
  "Print the contents of the buffer between start and end with n characters of context"
  (let ((before (buffer-substring (max (point-min) (- start n)) start))
        (match (buffer-substring start end))
        (after (buffer-substring end (min (point-max) (+ end n)))))
    (concat before "|" match "|" after)))

(defun ds/match-context (n)
  "Print the current match with n characters of context"
  (ds/buffer-context (match-beginning 0) (match-end 0) n))

(defun ds/print (x)
  "Print with newline TODO: multiple args"
  (pp x)
  (terpri))

Add a set of lisp helpers

Add a set of lisp helpers


;; diffcourse-mode.el
;;
;; Major mode for diffcourse files.

;; to use diff-mode's font-locking as a base.
(require 'diff-mode)

;; If your keymap will have very few entries, then you may want to
;; consider ‘make-sparse-keymap’ rather than ‘make-keymap’.

;; (defvar diffcourse-mode-map
;;   (let ((map (make-keymap)))
;;     (define-key map "\C-j" 'newline-and-indent)
;;     map)
;;   "Keymap for diffcourse mode")

(add-to-list 'auto-mode-alist '("\\.diffcourse\\'" . diffcourse-mode))

;; font-lock support
;;
;; TODO: Need to investigate whether I can just front-load the
;; diffcourse font lock rules and then append the diff ones like this,
;; and have that work in some of the weirder circumstances
;; (e.g. leading %'s in header material) or whether that even matters.
;; Alternatively, could duplicate all the definitions here.  But that
;; would suck.
;;
;; TODO: real faces, support up to--say--5 without recylcing, 10 with?

(defvar diffcourse-font-lock-keywords
  (append
   (list
     '("^%\\*\\([ ].*\n\\|\n\\)" . diff-added-face) ;; level 1 header
     '("^%-\\([ ].*\n\\|\n\\)" . diff-added-face) ;; level 1 body
     '("^%[*]\\{2\\}\\([ ].*\n\\|\n\\)" . diff-removed-face) ;; level 2 header
     '("^%[-]\\{2\\}\\([ ].*\n\\|\n\\)" . diff-removed-face)) ;; level 2 body

   diff-font-lock-keywords))

;; TODO: figure out how not to have emacs strip trailing spaces *ever*
;; in this mode?

(defun diffcourse-mode ()
  "Major mode for inter-diff code review"
  (interactive)
  (kill-all-local-variables)
  ;; (set-syntax-table wpdl-mode-syntax-table)
  ;; (use-local-map diffcourse-mode-map)
  (set (make-local-variable 'font-lock-defaults) '(diffcourse-font-lock-keywords))
  (setq major-mode 'diffcourse-mode)
  (setq mode-name "Diffcourse")
  (run-hooks 'diffcourse-mode-hook))

(provide 'diffcourse-mode)

Add proof of concept emacs mode.

Add proof of concept emacs mode.

This still needs real faces to be even marginally useful.


;; backup in one place. flat, no tree structure
;; http://ergoemacs.org/emacs/emacs_set_backup_into_a_directory.html
(setq backup-directory-alist '(("" . "~/.emacs.d/emacs-backup")))

Add emacs.d/init.el file for backup file settings


; Sets emacs variables based on mode.
; A list of (major-mode . ((var1 . value1) (var2 . value2)))
; Mode can be nil, which gives default values.

((nil . ((indent-tabs-mode . nil)
         (c-basic-offset . 4)))
)

Add emacs config for indentation

Add emacs config for indentation


(require 'cl-lib)
(require 'xref)
(require 'merlin)

;;;###autoload
(defun merlin-xref-backend ()
  "Merlin backend for Xref."
  'merlin-xref)

(defun merlin-xref--line (loc)
  (save-excursion
    (goto-char loc)
    (buffer-substring (line-beginning-position) (line-end-position))))

(cl-defmethod xref-backend-references ((_backend (eql merlin-xref)) symbol)
  (mapcar
   (lambda (loc)
     (let ((pt (merlin/make-point (alist-get 'start loc))))
       (xref-make (merlin-xref--line pt)
                  (xref-make-buffer-location (current-buffer) pt))))
   (merlin--occurences)))

(cl-defmethod xref-backend-definitions ((_backend (eql merlin-xref)) symbol)
  (let* ((loc (merlin/locate))
         (file (alist-get 'file loc))
         (pos (alist-get 'pos loc))
         (line (alist-get 'line pos))
         (col (alist-get 'col pos))
         (desc (merlin-xref--line (merlin/make-point pos))))
    (list (xref-make desc (xref-make-file-location file line col)))))

(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql merlin-xref)))
  nil)

(provide 'merlin-xref)

Add merlin based xref backend

Add merlin based xref backend


;;; starter-kit-ruby.el --- Some helpful Ruby code
;;
;; Part of the Emacs Starter Kit

;; Until this makes it into ELPA:
(autoload 'ruby-mode "ruby-mode" "" t)
(autoload 'inf-ruby "inf-ruby" "" t)
(autoload 'run-ruby "inf-ruby" "" t)

(eval-after-load 'ruby-mode
  '(progn
     (require 'inf-ruby)
     (require 'ruby-compilation)

     (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
     (define-key ruby-mode-map (kbd "C-c l") "lambda")))

(global-set-key (kbd "C-h r") 'ri)

;; We never want to edit Rubinius bytecode
(add-to-list 'completion-ignored-extensions ".rbc")

;; TODO: set up ri
;; TODO: electric
;; TODO: flymake

(provide 'starter-kit-ruby)
;; starter-kit-ruby.el ends here

;;; starter-kit-ruby.el --- Some helpful Ruby code
;;
;; Part of the Emacs Starter Kit

;; Until this makes it into ELPA:
(autoload 'ruby-mode "ruby-mode" "" t)
(autoload 'inf-ruby "inf-ruby" "" t)
(autoload 'run-ruby "inf-ruby" "" t)

(eval-after-load 'ruby-mode
  '(progn
     (require 'inf-ruby)
     (require 'ruby-compilation)

     (define-key ruby-mode-map (kbd "RET") 'reindent-then-newline-and-indent)
     (define-key ruby-mode-map (kbd "C-c l") "lambda")))

(global-set-key (kbd "C-h r") 'ri)

;; We never want to edit Rubinius bytecode
(add-to-list 'completion-ignored-extensions ".rbc")

;; Clear the compilation buffer between test runs.
(eval-after-load 'ruby-compilation
  '(progn
     (defadvice ruby-do-run-w/compilation (before kill-buffer (name cmdlist))
       (let ((comp-buffer-name (format "*%s*" name)))
         (when (get-buffer comp-buffer-name)
           (with-current-buffer comp-buffer-name
             (delete-region (point-min) (point-max))))))
     (ad-activate 'ruby-do-run-w/compilation)))

;; TODO: set up ri
;; TODO: electric
;; TODO: flymake

(provide 'starter-kit-ruby)
;; starter-kit-ruby.el ends here

Clear compilation buffer in between test runs.


;; Ruby
(autoload 'rhtml-mode "rhtml-mode")
(add-to-list 'auto-mode-alist '("\\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.watchr$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.gemspec$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("capfile" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.erb$" . rhtml-mode))

Enable ruby-mode for various ruby files.


; Copyright (c) 2003 The Regents of The University of Michigan
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are
; met: redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer;
; redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution;
; neither the name of the copyright holders nor the names of its
; contributors may be used to endorse or promote products derived from
; this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;
; Authors: Nathan Binkert
;          Steve Reinhardt

(c-add-style "m5"
             '((c-basic-offset . 4)
               (c-offsets-alist . ((substatement-open . 0)
                                   (inline-open . 0)
                                   (block-open . -4)
                                   (case-label . 2)
                                   (label . 2)
                                   (statement-case-intro . 2)
                                   (statement-case-open . 2)
                                   (access-label . -2)))))

Add m5 emacs style file.

Add m5 emacs style file.

--HG--
extra : convert_revision : bccc866984c98d974c1745f125293d781d6d0b1e


(require 'tempo)
;; (setq tempo-interactive t)

(tempo-define-template "org-digraph"
                       '(> "#+begin_src dot :file " (p "Filename: ") ".png\n"
                           > "digraph G {\n"
                           > "}\n"
                           > "#+end_src\n"))

(provide 'clgc-tempo)

Add org-digraph template using tempo

Add org-digraph template using tempo


(setq lexical-binding t)

(with-current-buffer (get-buffer "*example*")
  (goto-char (point-min))
  (mpd-parse psl-tokens))

(defvar psl-tokens
  '((expr      (block defvar deffun number object lambda id))
    (defvar    "defvar" id "=" expr "in" expr)
    (deffun    "deffun" id params expr "in" expr)
    (lambda    "lambda" params expr)
    (number    "[0-9]+")
    (block     "{" exprs "}")
    (exprs     expr ((";" exprs) ""))

    ;; Identifiers
    (id        "[a-zA-Z]+")
    (ids       id (("," id) ""))
    (params    "(" ids ")")

    ;; Function application
    (funcapp   "(" exprs ")")

    ;; Objects
    (pairs     pair (("," pairs) ""))
    (pair      id ":" expr)
    (object    "{" ("" pairs) "}")))

(defun mpd-parse (tokens)
  "Return the next item in the current buffer."
  (let ((start (point)))
    (dolist (token tokens)
      (message (format "Trying %s" (car token)))
      (let ((result (mpd-match tokens (cdr token))))
        (if (eq result 'no-match)
            (goto-char start)
          (return (cons (car token) result)))))))

(defun mpd-skip-space ()
  "Skip over whitespace."
  (search-forward-regexp "[[:space:]]*"))

(defun mpd--cons-if (head tail)
  "Cons only if tail is no `no-match'."
  (if (not (eq tail 'no-match))
      (cons head tail)
    'no-match))

(defun mpd-match (tokens expr)
  "Return the matching tokens if expr matches, otherwise return
the symbol `no-match'."
  (if (null expr)
      ()
    (mpd-skip-space)
    (let ((this (car expr))
          (rest (cdr expr)))
      (etypecase this
        (string
         (if (looking-at this)
           (let* ((end (match-end 0))
                  (start (point))
                  (capture (buffer-substring (point) end)))
             (goto-char end)
             (let ((result (mpd-match tokens rest)))
               (if (not (eq result 'no-match))
                   (cons capture result)
                 (goto-char start)
                 'no-match)))
           'no-match))
        (symbol
         (let ((result (mpd-match tokens (cdr (assoc this tokens)))))
           (if (not (eq result 'no-match))
               (mpd--cons-if (cons this result) (mpd-match tokens rest))
             'no-match)))
        (list
         (dolist (item this 'no-match)
           (let ((res1 (mpd-match tokens (if (listp item) item (list item)))))
             (if (not (eq res1 'no-match))
                 (let ((res2 (mpd-match tokens rest)))
                   (if (not (eq res2 'no-match))
                       (return (append res1 res2))))))))))))

Add beginnings of a ParselTongue parser.


;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((c++-mode
  (flycheck-clang-standard-library . "libc++")
  (cmake-ide-build-dir . "build")))

Add config for Emacs cmake-ide and flycheck-clang


;; This file is automatically generated by the multiple-cursors extension.
;; It keeps track of your preferences for running commands with multiple cursors.

(setq mc/cmds-to-run-for-all
      '(
        about-emacs
        autopair-insert-opening
        backward-sexp
        beginning-of-defun
        compile
        dabbrev-expand
        erlang-electric-comma
        erlang-electric-gt
        erlang-electric-semicolon
        forward-sexp
        indent-for-tab-command
        kill-region
        mark-sexp
        org-beginning-of-line
        org-delete-char
        org-end-of-line
        paredit-forward-delete
        paredit-forward-kill-word
        split-line
        wgrep-finish-edit
        yas-abort-snippet
        yas-expand
        ))

(setq mc/cmds-to-run-once
      '(
        autopair-skip-close-maybe
        helm-M-x
        mac-mwheel-scroll
        org-self-insert-command
        ))

Add customizations for emcas multiple cursors


;; This file configures org modes publish functionality to generate the gh-pages site for this project.
;; Load this file/buffer and then execute: M-x org-publish-project RET gh-pages RET

(setq org-publish-project-alist
      '(("gh-notes"
	  :base-directory "./org"
	  :base-extension "org"
	  :publishing-directory "./gh-pages"
	  :recursive t
	  :publishing-function org-html-publish-to-html
	  :headline-levels 4
	  :auto-preamble t)
	("gh-pages" :components ("gh-notes"))))

Add org-mode publishing setup source file


(defvar-local +lsp--flycheck-eglot--current-errors nil)

(defun +lsp--flycheck-eglot-init (checker callback)
  "CHECKER is the checker (eglot).
CALLBACK is the function that we need to call when we are done, on all the errors."
  (eglot-flymake-backend #'+lsp--flycheck-eglot--on-diagnostics)
  (funcall callback 'finished +lsp--flycheck-eglot--current-errors))

(defun +lsp--flycheck-eglot--on-diagnostics (diags &rest _)
  (cl-labels
      ((flymake-diag->flycheck-err
        (diag)
        (with-current-buffer (flymake--diag-buffer diag)
          (flycheck-error-new-at-pos
           (flymake--diag-beg diag)
           (pcase (flymake--diag-type diag)
             ('eglot-note 'info)
             ('eglot-warning 'warning)
             ('eglot-error 'error)
             (_ (error "Unknown diagnostic type, %S" diag)))
           (flymake--diag-text diag)
           :end-pos (flymake--diag-end diag)
           :checker 'eglot
           :buffer (current-buffer)
           :filename (buffer-file-name)))))
    (setq +lsp--flycheck-eglot--current-errors
          (mapcar #'flymake-diag->flycheck-err diags))
    ;; Call Flycheck to update the diagnostics annotations
    (flycheck-buffer-deferred)))

(defun +lsp--flycheck-eglot-available-p ()
  (bound-and-true-p eglot--managed-mode))

(flycheck-define-generic-checker 'eglot
  "Report `eglot' diagnostics using `flycheck'."
  :start #'+lsp--flycheck-eglot-init
  :predicate #'+lsp--flycheck-eglot-available-p
  :modes '(prog-mode text-mode))

(push 'eglot flycheck-checkers)

(defun +lsp-eglot-prefer-flycheck-h ()
  (when eglot--managed-mode
    (flymake-mode -1)
    (when-let ((current-checker (flycheck-get-checker-for-buffer)))
      (unless (equal current-checker 'eglot)
        (flycheck-add-next-checker 'eglot current-checker)))
    (flycheck-add-mode 'eglot major-mode)
    (flycheck-mode 1)
    ;; Call flycheck on initilization to make sure to display initial
    ;; errors
    (flycheck-buffer-deferred)))

(add-hook 'eglot-managed-mode-hook '+lsp-eglot-prefer-flycheck-h)

(with-eval-after-load
    (when (and
           (not (fboundp 'flymake--diag-buffer))
           (fboundp 'flymake--diag-locus))
      (defalias 'flymake--diag-buffer 'flymake--diag-locus))
  )

(provide 'eglot-flycheck_init)

Add flycheck support to elgot

Add flycheck support to elgot


(defun find-git-repo (dir)
  (if (string= "/" dir)
      (message "not in a git repo.")
    (if (file-exists-p (expand-file-name ".git/" dir))
        dir
      (find-git-repo (expand-file-name "../" dir)))))

(defun rspec-buffer ()
  (interactive)
  (let ((default-directory (find-git-repo default-directory))
        (command (concat "bundle exec rspec -c " (buffer-file-name (window-buffer)))))
    (async-shell-command command)))

(global-set-key (kbd "C-c C-e") 'rspec-buffer)

Add fast execution of rspec

Add fast execution of rspec


;;
;; Author: Rafael Campos Nunes
;; Email: <rafaelnunes at engineer dot com>

;; Add MELPA repository
(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list
   'package-archives
   '("melpa" . "http://melpa.org/packages/")
   t)
  (package-initialize))

;; Disabling tool-bar-mode
(tool-bar-mode 0)
;; To view the column index
(column-number-mode 1)
;; To view line numbers
(global-linum-mode 1)

;; Wakatime configuration
(setq wakatime-api-key "{your_api_key}")
(setq wakatime-python-bin "{your_python_bin}")

(global-wakatime-mode 1)

;; Better keys for split/delete windows
(global-set-key (kbd "M-3") 'delete-other-windows)
(global-set-key (kbd "M-4") 'split-window-below)
(global-set-key (kbd "M-$") 'split-window-right)
(global-set-key (kbd "M-RET") 'other-window)
(global-set-key (kbd "M-0") 'delete-window)

(custom-set-variables
 '(custom-enabled-themes (quote (tsdh-dark))))

(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.
 )

Add my emacs configuration file

Add my emacs configuration file

Signed-off-by: Rafael Campos Nunes <42f0a9af43f2538fd3153aecc7c3ff958e89d724@engineer.com>


;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((c++-mode
  (flycheck-checker . c/c++-gcc)
  (flycheck-gcc-language-standard . "c++11")
  (eval . (setq flycheck-gcc-include-path
                (list "../include"
                      (replace-regexp-in-string
                       "\n$" ""
                       (shell-command-to-string "llvm-config --includedir")))))))

Add flycheck options for fact-generator

Add flycheck options for fact-generator


;;; lang/latex/+ref.el -*- lexical-binding: t; -*-

(defvar +latex-bibtex-file ""
  "File AUCTeX (specifically RefTeX) uses to search for citations.")

(def-package! reftex
  :hook ((latex-mode LaTeX-mode) . turn-on-reftex)
  :init
  (setq reftex-plug-into-AUCTeX t
        reftex-toc-split-windows-fraction 0.3)
  :config
  ;; Get ReTeX working with biblatex
  ;; http://tex.stackexchange.com/questions/31966/setting-up-reftex-with-biblatex-citation-commands/31992#31992
  (setq reftex-cite-format
        '((?t . "\\textcite[]{%l}")
          (?a . "\\autocite[]{%l}")
          (?c . "\\cite[]{%l}")
          (?s . "\\smartcite[]{%l}")
          (?f . "\\footcite[]{%l}")
          (?n . "\\nocite{%l}")
          (?b . "\\blockcquote[]{%l}{}")))
  (unless (string-empty-p +latex-bibtex-file)
    (setq reftex-default-bibliography (list (expand-file-name +latex-bibtex-file))))
  (map! :map reftex-mode-map
        :localleader :n ";" 'reftex-toc)
  (add-hook! 'reftex-toc-mode-hook
    (reftex-toc-rescan)
    (map! :local
          :e "j"   #'next-line
          :e "k"   #'previous-line
          :e "q"   #'kill-buffer-and-window
          :e "ESC" #'kill-buffer-and-window)))

(def-package! company-reftex
  :when (featurep! :completion company)
  :after reftex
  :config
  (set-company-backend! 'reftex-mode 'company-reftex-labels 'company-reftex-citations))

(def-package! bibtex
  :defer t
  :config
  (setq bibtex-dialect 'biblatex
        bibtex-align-at-equal-sign t
        bibtex-text-indentation 20)
  (define-key bibtex-mode-map (kbd "C-c \\") #'bibtex-fill-entry))

(def-package! ivy-bibtex
  :when (featurep! :completion ivy)
  :commands ivy-bibtex)

(def-package! helm-bibtex
  :when (featurep! :completion helm)
  :commands helm-bibtex)

(after! bibtex-completion
  (unless (string-empty-p +latex-bibtex-file)
    (setq bibtex-completion-bibliography (list (expand-file-name +latex-bibtex-file)))))

Move referencing setup into different file