(use-package auto-package-update :ensure t)
(global-set-key (kbd "H-k") 'global-set-key)
(global-set-key (kbd "H-s") 'save-buffer)
(global-set-key (kbd "H-S") 'save-some-buffers)
(global-set-key (kbd "H-f") 'fdx/visit-or-projectile-visit)
(global-set-key (kbd "H-F") 'ido-find-file)
(global-set-key (kbd "H-D f") 'fdx/delete-file-and-buffer)
(global-set-key (kbd "H-D r") 'fdx/rename-current-file)
(global-set-key (kbd "H-D m") 'fdx/chmod-current-file)
(global-set-key (kbd "H-D t") 'fdx/touch-current-file)
(global-set-key (kbd "H--") 'kill-whole-line)
(global-set-key (kbd "H-d") 'fdx/duplicate-line)
(global-set-key (kbd "<H-S-up>") 'fdx/move-line-up)
(global-set-key (kbd "<H-S-down>") 'fdx/move-line-down)
Auto revert buffers
(global-auto-revert-mode 1)
Reload file with <f5>
(global-set-key (kbd "<f5>") 'revert-buffer)
(defun fdx/reload-emacs-configuration ()
"Reload emacs configuration"
(interactive)
(org-babel-load-file (expand-file-name "~/.emacs.d/Readme.org")))
(global-set-key (kbd "<H-f12>") 'fdx/reload-emacs-configuration)
(global-set-key (kbd "S-<f12>") 'package-refresh-contents)
(setq-default toggle-truncate-lines t)
(setq-default word-wrap t)
(setq inhibit-startup-message t)
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
;; (menu-bar-mode 1)
(fset 'yes-or-no-p 'y-or-n-p)
(blink-cursor-mode 0)
(show-paren-mode)
(use-package doom-themes :ensure t)
(load-theme 'doom-ir-black t)
(custom-set-faces
`(default ((t (:family "Inconsolata"
;; :foundry "unknown"
:slant normal
:weight normal
:height ,260
:width normal)))))
(use-package try :ensure t)
(use-package which-key
:ensure t
:config (which-key-mode))
Save backup files in it’s own directory
(setq backup-directory-alist `(("." . "~/.emacs.d/backup-files")))
Set backup by copying
(setq backup-by-copying t)
Configure how much to backup
(setq delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t)
;;;###autoload
(defun fdx/reindent-buffer ()
"Indent the current buffer."
(interactive)
(delete-trailing-whitespace)
(indent-region (point-min) (point-max))
(untabify (point-min) (point-max)))
(global-set-key (kbd "H-=") 'fdx/reindent-buffer)
(use-package indent-guide
:ensure t
:config
(progn
))
(require 'indent-guide)
(use-package highlight-indent-guides
:ensure t
:init
(progn
(setq highlight-indent-guides-method 'fill)
(setq highlight-indent-guides-auto-odd-face-perc 2)
(setq highlight-indent-guides-auto-even-face-perc 5)
))
(require 'highlight-indent-guides)
(setq indent-tabs-mode nil) ; And force use of spaces
(setq-default indent-tabs-mode nil)
(setq c-basic-offset 2) ; indents 2 chars
(setq tab-width 2) ; and 2 char wide for TAB
(setq css-indent-offset 2) ; set CSS indentation to 2 spaces
(setq js-indent-level 2) ; set JavaScript indentation to 2 spaces
(setq coffee-tab-width 2) ; set CoffeeScript indentation to 2 spaces
(setq typescript-indent-level 2) ; set TypeScript indentation to 2 spaces
(global-set-key (kbd "C-c i") 'align-regexp)
(use-package whitespace-cleanup-mode :ensure t)
(setq org-structure-template-alist
'(
("-" . "src")
("q" . "quote")
("v" . "verse")
("r" . "src ruby")
("l" . "src emacs-lisp")
("s" . "src sh")
("C" . "comment")
("e" . "example")
("h" . "export html")
("a" . "export ascii")
("c" . "center")
("E" . "export")
))
(setq org-clock-into-drawer "CLOCKING")
(setq org-duration-format (quote h:mm))
Pretty bullets for org-mode
(use-package org-bullets
:ensure t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
;;;###autoload
(defun fdx/populate-org-shots (ARG)
"Populate {{{shot(n)}}}* macros on current buffer"
(interactive "p")
(save-excursion
(beginning-of-buffer)
(kmacro-set-counter 1)
(while (search-forward "{{{shot(" nil t)
(kmacro-insert-counter ARG)
(let ((start (point)))
(search-forward-regexp "\\(,\.+)\\|)}}}\\)")
(let ((end (match-beginning 0)))
(delete-region start end)
)
))))
;;;###autoload
(defun fdx/insert-and-populate-org-shots ()
"Insert {{{shot()}}} and repopulate shots on buffer"
(interactive)
(insert "{{{shot()}}}")
(fdx/populate-org-shots t))
(global-set-key (kbd "H-a g") 'org-agenda)
(use-package projectile :ensure t)
;;;###autoload
(defun fdx/visit-or-projectile-visit (&optional a b)
(interactive)
(if (projectile-project-p)
(call-interactively #'counsel-projectile-find-file)
(call-interactively #'counsel-find-file)))
;;;###autoload
(defun fdx/ag-or-projectile-ag (&optional a b)
(interactive)
(if (projectile-project-p)
(call-interactively #'projectile-ag)
(call-interactively #'ag)))
(global-set-key (kbd "H-g") 'projectile-ripgrep)
(global-set-key (kbd "H-G") 'ag)
(use-package ag :ensure t)
(setq ag-reuse-buffers t)
(use-package ripgrep :ensure t)
(use-package wgrep :ensure t)
(use-package wgrep-ag :ensure t)
(require 'wgrep)
(require 'wgrep-ag)
(setq wgrep-auto-save-buffer t)
(use-package magit :ensure t)
(global-set-key (kbd "C-c g") 'magit-status)
(global-set-key (kbd "C-c C-g") 'magit-status)
(defadvice magit-status (around magit-fullscreen activate)
(window-configuration-to-register :magit-fullscreen)
ad-do-it
(delete-other-windows)
(magit-section-show-level-2-all))
(defun magit-quit-session ()
"Restores the previous window configuration and kills the magit buffer"
(interactive)
(kill-buffer)
(jump-to-register :magit-fullscreen))
(define-key magit-status-mode-map (kbd "q") 'magit-quit-session)
(custom-set-variables
'(git-commit-fill-column 1000)
'(git-commit-finish-query-functions nil)
'(git-commit-summary-max-length 1000))
(use-package git-timemachine :ensure t)
(put 'dired-find-alternate-file 'disabled nil)
(setq global-auto-revert-non-file-buffers t)
(setq auto-revert-verbose nil)
(defun dired-back-to-top ()
(interactive)
(beginning-of-buffer)
(dired-next-line 1)
(dired-next-line 1)
(dired-next-line 1))
(define-key dired-mode-map
(vector 'remap 'beginning-of-buffer) 'dired-back-to-top)
(defun dired-jump-to-bottom ()
(interactive)
(end-of-buffer)
(dired-next-line -1))
(define-key dired-mode-map
(vector 'remap 'end-of-buffer) 'dired-jump-to-bottom)
(setq dired-listing-switches "-aBhl --group-directories-first")
(setq-default dired-omit-files-p nil) ; Buffer-local variable
(setq dired-omit-files "^\\.?#\\|^\\.$\\|^\\.[^\\.]")
;; (setq dired-omit-mode t) ; Turn on Omit mode.
(setq dired-omit-verbose nil) ; Turn off Omit mode messages.
(require 'dired-x)
(add-hook 'dired-mode-hook
(lambda ()
(dired-hide-details-mode t)))
Kill all buffers except for the current one
;;;###autoload
(defun fdx/kill-other-buffers ()
"Kill all buffers but the current one.
Don't mess with special buffers."
(interactive)
(dolist (buffer (buffer-list))
(unless (or (eql buffer (current-buffer)) (not (buffer-file-name buffer)))
(progn
(kill-buffer buffer)
))
(delete-other-windows)))
Bind it to C-c k
(global-set-key (kbd "C-c k") 'fdx/kill-other-buffers)
(global-set-key (kbd "C-x C-w")
(lambda ()
(interactive)
(switch-to-buffer "*scratch*")))
All buffers, try to reuse windows across all frames
(defun fdx/reuse-buffers ()
(interactive)
(add-to-list 'display-buffer-alist
'(".*". (display-buffer-reuse-window .
((reusable-frames . t))))))
When finding a file, if the parent directory doesn’t exist, create it first
;; Make directories on the fly
(defun make-parent-directory ()
"Make sure the directory of `buffer-file-name' exists."
(make-directory (file-name-directory buffer-file-name) t))
(add-hook 'find-file-not-found-functions #'make-parent-directory)
(global-set-key (kbd "H-<left>") 'windmove-left)
(global-set-key (kbd "H-<right>") 'windmove-right)
(global-set-key (kbd "H-<up>") 'windmove-up)
(global-set-key (kbd "H-<down>") 'windmove-down)
(global-set-key (kbd "H-w") 'balance-windows)
Navigate window configuration history
(winner-mode 1)
(use-package centered-cursor-mode :ensure t)
(setq split-width-threshold 0)
(setq split-height-threshold nil)
(eval-after-load "ruby-mode"
'(progn
(define-key ruby-mode-map (kbd "C-c C-c") 'fdx/seeing-is-believing-run-as-xmpfilter-and-reload-mode)
(define-key ruby-mode-map (kbd "H-;") 'fdx/comment-dwim)
(define-key ruby-mode-map (kbd "C-;") 'fdx/comment-dwim)
(define-key ruby-mode-map (kbd "H-=") 'fdx/reindent-buffer)
(define-key ruby-mode-map (kbd "C-c C-c") 'xmp)
(define-key ruby-mode-map (kbd "C-c c") 'xmp)
(define-key ruby-mode-map (kbd "C-;") 'comment-dwim)
))
(load
(expand-file-name "~/.emacs.d/fdx/vendor/rcodetools.el")
t)
(setq xmpfilter-command-name
"ruby -S seeing_is_believing --xmpfilter-style")
;; (setq xmpfilter-command-name
;; "ruby -S seeing_is_believing -r ~/lib/xmp_base --xmpfilter-style")
(use-package rvm
:ensure t
:config
(rvm-use-default))
(use-package rspec-mode
:bind (
("H-r r" . rspec-rerun)
("H-r t" . rspec-toggle-spec-and-target)
("H-r v" . rspec-verify)
("H-r a" . rspec-verify-all)
("H-r H-a" . rspec-verify-all)
("H-r s" . rspec-verify-single)
("H-r f" . rspec-run-last-failed)
)
:ensure t)
(load (expand-file-name "~/.emacs.d/fdx/vendor/ruby-runner-mode/ruby-runner-mode.el") t)
(global-set-key (kbd "H-i i") 'rr/rerun)
(which-key-add-key-based-replacements "H-i r" "RSpec")
(rr/global-set-key "H-i r a" "bundle exec rspec")
;; (rr/global-set-key-current-file "H-i r v" "rspec")
;; (rr/global-set-key-current-file "H-6" "rspec")
(which-key-add-key-based-replacements "H-i u" "Rubocop")
(rr/global-set-key "H-i u a" "bundle exec rubocop")
(rr/global-set-key "H-i u A" "bundle exec rubocop --autocorrect && bundle exec rubocop")
(rr/global-set-key "H-i u T" "bundle exec rubocop --regenerate-todo")
(which-key-add-key-based-replacements "H-i b" "Bundle")
(rr/global-set-key-multiple "H-i b b" '("bundle install" "pessimize -c patch --no-backup" "bundle install"))
(rr/global-set-key-multiple "H-i b B" '("bundle update" "pessimize -c patch --no-backup" "bundle install"))
;; (rr/global-set-key "H-i r" "ruby" (buffer-file-name)) <- this doesn't work
(use-package ruby-electric :ensure t)
(require 'ruby-electric)
(electric-pair-mode t)
;;;###autoload
(defun fdx/bundle ()
"Run Pessimize."
(interactive)
(compile "bundle install"))
;;;###autoload
(defun fdx/bundle-update ()
"Run Pessimize."
(interactive)
(compile "bundle update"))
;;;###autoload
(defun fdx/pessimize ()
"Run Pessimize."
(interactive)
(compile "pessimize -c patch --no-backup"))
;;;###autoload
(defun fdx/bundle-pessimize ()
"Run bundel install and pessimize."
(interactive)
(compile "bundle install && pessimize -c patch --no-backup"))
;;;###autoload
(defun fdx/bundle-update-pessimize ()
"Run bundle update and pessimize."
(interactive)
(compile "bundle update && pessimize -c patch --no-backup"))
;;;###autoload
(defun fdx/rspec-init ()
"Run bundle update and pessimize."
(interactive)
(compile "bundle exec rspec --init"))
Convert a nested set of classes and modules to one line with the namespace joined by “::”
;;;###autoload
(defun fdx/inline-ruby-namespace (beg end)
(interactive "r")
(let ((selection (buffer-substring-no-properties beg end)))
(let
((inlined (string-join (split-string (s-replace "\n" "" selection) "\s*\\(?:module\\|class\\)\s+") "::")))
;;(message selection)
(message inlined)
(delete-region beg end)
(insert inlined)
)
)
)
(use-package ruby-refactor :ensure t)
(setq ruby-flymake-use-rubocop-if-available nil)
(add-hook 'before-save-hook 'whitespace-cleanup)
(use-package counsel :ensure t)
(setq ivy-initial-inputs-alist nil)
(setq ivy-re-builders-alist '((swiper . ivy--regex-plus)
(t . ivy--regex-fuzzy)))
(use-package counsel-projectile :ensure t)
(use-package swiper
:ensure t
:bind (
("C-s" . swiper)
("C-r" . swiper)
("C-c C-r" . ivy-resume)
("M-x" . counsel-M-x)
("C-x C-f" . counsel-find-file)
)
:config
(progn
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
(global-set-key (kbd "<f1> l") 'counsel-find-library)
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
(define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)
))
(use-package ivy
:ensure t
:config
(require 'ivy))
(use-package flx
:ensure t
:config
(require 'flx))
(setq ivy-use-virtual-buffers t)
;; intentional space before end of string
(setq ivy-count-format "(%d/%d) ")
(setq ivy-initial-inputs-alist nil)
(setq ivy-re-builders-alist
'((swiper . ivy--regex-plus)
(t . ivy--regex-fuzzy)))
;; Use C-j for immediate termination with current value
(define-key ivy-minibuffer-map (kbd "C-j") #'ivy-immediate-done)
;; Use RET for continuing completion for that directory
(define-key ivy-minibuffer-map (kbd "RET") #'ivy-alt-done)
(ivy-mode 1)
(use-package yasnippet
:ensure t
:init
(progn
(setq yas-snippet-dirs
(list (expand-file-name "~/.emacs.d/fdx/snippets")))
(yas-global-mode 1)
))
(require 'yasnippet)
;;;###autoload
(defun fdx/recompile-snippets ()
(interactive)
(shell-command
(concat "rm -rf "
user-emacs-directory
"fdx/snippets/**/.yas-compiled-snippets.el*"))
(yas/recompile-all)
(yas/reload-all))
(global-set-key (kbd "S-<f7>") 'fdx/recompile-snippets)
(global-set-key (kbd "<backtab>") 'yas-expand-from-trigger-key)
(global-set-key (kbd "C-<tab>") 'yas-insert-snippet)
(use-package undo-tree
:ensure t
:init
(global-undo-tree-mode))
(setq undo-tree-auto-save-history nil)
(global-set-key (kbd "H-0") 'bookmark-jump)
(global-set-key (kbd "H-)") 'bookmark-set)
(use-package web-mode :ensure t)
(use-package emmet-mode :ensure t)
(use-package slim-mode
:bind (
("H-h" . emmet-expand-yas)
("H-=" . fdx/reindent-buffer)
)
:ensure t)
(global-set-key (kbd "H-j") (lambda ()
(interactive)
(join-line -1)))
(use-package vlf :ensure t)
(use-package adoc-mode :ensure t)
(add-hook 'adoc-mode-hook (lambda()
(buffer-face-mode -1)
(global-set-key (kbd "C-c t t") 'fdx/populate-adoc-shots)))
;;;###autoload
(defun fdx/populate-adoc-shots (ARG)
"Populate {{{shot(n)}}} macros on current buffer"
(interactive "p")
(save-excursion
(beginning-of-buffer)
(kmacro-set-counter 1)
(while (search-forward "shot::[" nil t)
(let ((start (point)))
(search-forward-regexp ",\\|]" nil nil)
(left-char)
(delete-region start (point)))
(kmacro-insert-counter ARG))
(message "Done populating shot macros.")))
;;;###autoload
(defun fdx/insert-and-populate-adoc-shots ()
"Insert {{{shot()}}} and repopulate shots on buffer"
(interactive)
(insert "shot::[]")
(fdx/populate-adoc-shots t))
;;;###autoload
(defun fdx/populate-md-shots (ARG)
"Populate <!-- shot(n) --> macros on current buffer"
(interactive "p")
(save-excursion
(beginning-of-buffer)
(kmacro-set-counter 1)
(while (search-forward "<!-- shot(" nil t)
(let ((start (point)))
(search-forward-regexp ",\\|)" nil nil)
(left-char)
(delete-region start (point)))
(kmacro-insert-counter ARG))
(message "Done populating shot macros.")))
;;;###autoload
(defun fdx/insert-and-populate-md-shots ()
"Insert {{{shot()}}} and repopulate shots on buffer"
(interactive)
(insert "<!-- shot() -->")
(fdx/populate-md-shots t))
;;;###autoload
(defun fdx/populate-hm-shots (ARG)
"Populate [📽 nw] macros on current buffer"
(interactive "p")
(save-excursion
(beginning-of-buffer)
(kmacro-set-counter 1)
(while (search-forward "[📽 " nil t)
(let ((start (point)))
(search-forward-regexp ",\\|]" nil nil)
(left-char)
(delete-region start (point)))
(kmacro-insert-counter ARG))
(message "Done populating shots.")))
;;;###autoload
(defun fdx/insert-and-populate-hm-shots ()
"Insert [📽 ] and repopulate shots on buffer"
(interactive)
(insert "[📽 ]")
(fdx/populate-hm-shots t))
(column-number-mode)
(setq fdx/font-size-increment 5)
;;;###autoload
(defun fdx/decrease-font ()
"Decrease the font for all buffers"
(interactive)
(let ((old-face-attribute (face-attribute 'default :height)))
(set-face-attribute 'default nil :height (+ old-face-attribute fdx/font-size-increment))))
;;;###autoload
(defun fdx/increase-font ()
"Increase the font for all buffers"
(interactive)
(let ((old-face-attribute (face-attribute 'default :height)))
(set-face-attribute 'default nil :height (- old-face-attribute fdx/font-size-increment))))
(global-set-key (kbd "H-]") 'fdx/increase-font)
(global-set-key (kbd "H-[") 'fdx/decrease-font)
(defun no-op () (interactive))
(use-package multiple-cursors :ensure t)
(require 'multiple-cursors)
(global-set-key (kbd "C-c C-a") 'mc/edit-lines)
(global-set-key (kbd "C-M-<return>") 'mc/edit-lines)
(global-set-key (kbd "C-c a") 'mc/mark-all-like-this)
(global-set-key (kbd "H-.") 'mc/mark-next-like-this)
(global-set-key (kbd "H-,") 'mc/mark-previous-like-this)
(global-set-key (kbd "H->") 'mc/skip-to-next-like-this)
(global-set-key (kbd "H-p") 'mc/insert-numbers)
(use-package expand-region :ensure t)
(require 'expand-region)
(setq expand-region-fast-keys-enabled nil)
(global-set-key (kbd "H-e") 'er/expand-region)
(global-set-key (kbd "C-c e") 'er/expand-region)
;;;###autoload
(defun fdx/reload-browser (&optional by)
"Reload web browser"
(interactive)
(save-some-buffers)
(save-window-excursion (async-shell-command "~/bin/reload-browser"))
;; (kill-buffer "*Async Shell Command*")
)
;;;###autoload
(defun fdx/send-up-enter-to-current-window (&optional list)
"Reload web browser"
(interactive)
(save-some-buffers)
(save-window-excursion (async-shell-command "~/bin/send_to_current_window \"<Up>\" \"<Return>\""))
;; (kill-buffer "*Async Shell Command*")
)
;;;###autoload
(defun fdx/set-current-window (&optional by)
"Reload web browser"
(interactive)
(save-some-buffers)
(save-window-excursion (async-shell-command "~/bin/set_current_window"))
;; (kill-buffer "*Async Shell Command*")
)
;;;###autoload
(defun fdx/save-and-reload-browser (&optional by)
"Save current buffer and reload web browser"
(interactive)
(save-buffer)
(fdx/reload-browser)
)
;;;###autoload
(defun fdx/save-and-reload-browser-with-delay (&optional by)
"Save current buffer and reload web browser"
(interactive)
(save-buffer)
(sleep-for 0.3)
(fdx/reload-browser)
)
;;;###autoload
(defun fdx/save-recompile-and-reload-browser-with-delay (&optional by)
"Save current buffer and reload web browser"
(interactive)
(save-buffer)
(recompile)
(sleep-for 2.5)
(fdx/reload-browser)
)
Toggle window splits between vertical and horizontal splits
;;;###autoload
(defun fdx/toggle-window-split ()
(interactive)
(if (= (count-windows) 2)
(let* ((this-win-buffer (window-buffer))
(next-win-buffer (window-buffer (next-window)))
(this-win-edges (window-edges (selected-window)))
(next-win-edges (window-edges (next-window)))
(this-win-2nd (not (and (<= (car this-win-edges)
(car next-win-edges))
(<= (cadr this-win-edges)
(cadr next-win-edges)))))
(splitter
(if (= (car this-win-edges)
(car (window-edges (next-window))))
'split-window-horizontally
'split-window-vertically)))
(delete-other-windows)
(let ((first-win (selected-window)))
(funcall splitter)
(if this-win-2nd (other-window 1))
(set-window-buffer (selected-window) this-win-buffer)
(set-window-buffer (next-window) next-win-buffer)
(select-window first-win)
(if this-win-2nd (other-window 1))))))
(global-set-key (kbd "C-x /") 'fdx/toggle-window-split)
(use-package countdown :ensure t)
(global-set-key (kbd "H-m") 'recompile)
(global-set-key (kbd "H-b") 'compile)
(defun fdx/run-current-file ()
(interactive)
(save-buffer)
(compile (buffer-file-name)))
(defun fdx/run-current-ruby-file ()
(interactive)
(save-buffer)
(compile (concat "ruby " (buffer-file-name))))
;;;###autoload
(defun fdx/file-name-to-clipboard ()
"Copy current file name to clipboard"
(interactive)
(if (buffer-file-name)
(progn
(kill-new (buffer-file-name))
(message (buffer-file-name))
)
(message "Current buffer is not visiting a saved file")
)
)
(use-package dockerfile-mode :ensure t)
(use-package yaml-mode :ensure t)
(defun fdx/cucumber/run-rake-task(task)
(shell-command
(concat "cd /data/cucumber/content/ && bundle exec rake " task)
)
)
(defun fdx/cucumber/run-code-rake-task()
(interactive)
(fdx/cucumber/run-rake-task "code")
)
(defun fdx/cucumber/run-html-rake-task()
(interactive)
(fdx/cucumber/run-rake-task "html")
)
(defun fdx/cucumber/run-html-rake-task-and-reload-browser()
(interactive)
(fdx/populate-adoc-shots 1)
(save-buffer)
(fdx/cucumber/run-rake-task "html")
; (sleep-for 0.5)
(fdx/reload-browser)
)
(use-package adoc-mode :ensure t)
(add-hook 'adoc-mode-hook (lambda()
(buffer-face-mode t)
(global-set-key (kbd "C-c t t") 'fdx/populate-adoc-shots)))
(defun fdx/adoc-copy-include-line-from-file (p m)
(interactive "r")
(let* (
(lines-arg (fdx/adoc-get-lines-arg p m))
(file (fdx/adoc-strip-src-file-name (buffer-file-name)))
)
(kill-new (concat "include::" file "[" lines-arg "]"))
(message (concat "include::" file "[" lines-arg "]"))
)
)
(defun fdx/adoc-get-lines-arg (p m)
(if (region-active-p)
(if (eq p m)
(format "lines=%s" (line-number-at-pos p) (line-number-at-pos m))
(format "lines=%s..%s" (line-number-at-pos p) (line-number-at-pos m)))
)
)
(defun fdx/adoc-strip-src-file-name (file-name)
(replace-regexp-in-string "\\(\.\+/[0-9][0-9]/\\)" "../" (buffer-file-name) nil nil 1)
)
(delete-selection-mode 1)
(global-display-line-numbers-mode 0)
(display-line-numbers-mode 0)
(global-hl-line-mode 1)
;;;###autoload
(defun fdx/duplicate-line()
(interactive)
(move-beginning-of-line 1)
(kill-line)
(yank)
(open-line 1)
(next-line 1)
(yank))
;;;###autoload
(defun fdx/move-line-up ()
"Move up the current line."
(interactive)
(transpose-lines 1)
(forward-line -2)
(indent-according-to-mode))
;;;###autoload
(defun fdx/move-line-down ()
"Move down the current line."
(interactive)
(forward-line 1)
(transpose-lines 1)
(forward-line -1)
(indent-according-to-mode))
Commands for opening a new line above and below the current line
;;;###autoload
(defun fdx/open-line-below ()
"Open an empty line above the current one and move."
(interactive)
(move-end-of-line nil)
(newline-and-indent))
;;;###autoload
(defun fdx/open-line-above ()
"Open an empty line above the current one and move."
(interactive)
(move-beginning-of-line nil)
(newline-and-indent)
(forward-line -1)
(indent-according-to-mode))
Bind them
(global-set-key (kbd "C-<return>") 'fdx/open-line-below)
(global-set-key (kbd "C-S-<return>") 'fdx/open-line-above)
(defun fdx/paste-replacing-tabs-with-commas ()
(interactive)
(insert (replace-regexp-in-string "\t" "," (car kill-ring)))
)
(require 'iso-transl)
(save-place-mode 1)
Write backup files to own directory
(setq backup-directory-alist
`(("." . ,(expand-file-name
(expand-file-name "~/.emacs.d/backups")))))
Make backups of files, even when they’re in version control
(setq vc-make-backup-files t)
(setq create-lockfiles nil)
;; source: http://steve.yegge.googlepages.com/my-dot-emacs-file
(defun fdx/rename-current-file (new-name)
"Renames both current buffer and file it's visiting to NEW-NAME."
(interactive (list (read-string "sNew name: " (file-name-nondirectory (buffer-file-name)))))
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(if (get-buffer new-name)
(message "A buffer named '%s' already exists!" new-name)
(progn
(rename-file filename new-name 1)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil))))))
;;;###autoload
(defun fdx/delete-file-and-buffer ()
"Kill the current buffer and deletes the file it is visiting."
(interactive)
(let ((filename (buffer-file-name)))
(when filename
(if (vc-backend filename)
(vc-delete-file filename)
(progn
(delete-file filename)
(message "Deleted file %s" filename)
(kill-buffer))))))
(defun fdx/touch-current-file ()
"updates mtime on the file for the current buffer"
(interactive)
(shell-command (concat "touch " (shell-quote-argument (buffer-file-name))))
(clear-visited-file-modtime))
(defun fdx/chmod-current-file ()
"updates mtime on the file for the current buffer"
(interactive)
(chmod (buffer-file-name) (read-file-modes)))
(use-package company :ensure t)
(use-package lsp-mode :ensure t)
(add-hook 'ruby-mode-hook #'lsp)
;; (add-hook 'ruby-mode-hook #'lsp-deferred)
(use-package company-tabnine :ensure t)
(add-to-list 'company-backends #'company-tabnine)
(defun fdx/generate_ruby_framework_project (project-name)
"Reload web browser"
(interactive "sProject name: ")
(message (concat "Generating project " project-name))
(save-some-buffers)
(save-window-excursion (async-shell-command (concat "~/bin/ruby_framework " project-name)))
)
(defun fdx/generate_ruby_framework_web_project (project-name)
"Reload web browser"
(interactive "sProject name: ")
(message (concat "Generating project " project-name))
(save-some-buffers)
(save-window-excursion (async-shell-command (concat "~/bin/ruby_framework_web " project-name)))
)
(use-package typescript-mode :ensure t)
(server-start)
(use-package yafolding :ensure t)
(global-set-key (kbd "H-c") 'yafolding-toggle-element)
(global-set-key (kbd "H-C") 'yafolding-toggle-all)
(require 'ansi-color)
(defun fdx/display-ansi-colors ()
(interactive)
(ansi-color-apply-on-region (point-min) (point-max)))
(require 'ansi-color)
(defun endless/colorize-compilation ()
"Colorize from 'compilation-filter-start' to 'point'."
(let ((inhibit-read-only t))
(ansi-color-apply-on-region
compilation-filter-start (point))))
(add-hook 'compilation-filter-hook
'endless/colorize-compilation)
(use-package xterm-color :ensure t)
(require 'xterm-color)
(setq compilation-environment '("TERM=xterm-256color"))
(defun my/advice-compilation-filter (f proc string)
(funcall f proc (xterm-color-filter string)))
(advice-add 'compilation-filter :around #'my/advice-compilation-filter)
(setenv "TERM" "256colors")
(load
(expand-file-name "~/.emacs.d/fdx/vendor/livemarkup.el")
t)
(setq livemarkup-output-directory "/sandbox"
livemarkup-close-buffer-delete-temp-files t
livemarkup-refresh-interval 0.1
livemarkup-browser-open-function t)
(use-package noflet :ensure t :defer t)
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rake\\'" . 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 '("\\.gemspec\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Guardfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Jenkinsfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.rabl\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.env" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist (cons "\\.adoc\\'" 'adoc-mode))
(add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))