From 88ab401adc83bea6e1f571c54093dbc7f521e080 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Mon, 4 Jan 2021 19:52:04 -0800 Subject: emacs: rename the directory --- emacs/custom/fcuny-conf.el | 32 ++++++++++ emacs/custom/fcuny-defuns.el | 55 +++++++++++++++++ emacs/custom/fcuny-edit.el | 39 ++++++++++++ emacs/custom/fcuny-eshell.el | 39 ++++++++++++ emacs/custom/fcuny-flycheck.el | 27 +++++++++ emacs/custom/fcuny-git.el | 76 +++++++++++++++++++++++ emacs/custom/fcuny-navigation.el | 128 +++++++++++++++++++++++++++++++++++++++ emacs/custom/fcuny-org.el | 113 ++++++++++++++++++++++++++++++++++ emacs/custom/fcuny-prog.el | 99 ++++++++++++++++++++++++++++++ emacs/custom/fcuny-settings.el | 56 +++++++++++++++++ emacs/custom/fcuny-text.el | 31 ++++++++++ emacs/custom/fcuny-twitter.el | 13 ++++ emacs/custom/fcuny-ui.el | 83 +++++++++++++++++++++++++ emacs/custom/fcuny-vars.el | 16 +++++ emacs/etc/elfeed.org | 36 +++++++++++ emacs/etc/interview.org | 11 ++++ emacs/etc/new-project.org | 15 +++++ emacs/etc/weekly_review.org | 40 ++++++++++++ emacs/init.el | 41 +++++++++++++ emacs/lisp/fcuny-commands.el | 27 +++++++++ emacs/lisp/fcuny-flycheck-py.el | 6 ++ 21 files changed, 983 insertions(+) create mode 100644 emacs/custom/fcuny-conf.el create mode 100644 emacs/custom/fcuny-defuns.el create mode 100644 emacs/custom/fcuny-edit.el create mode 100644 emacs/custom/fcuny-eshell.el create mode 100644 emacs/custom/fcuny-flycheck.el create mode 100644 emacs/custom/fcuny-git.el create mode 100644 emacs/custom/fcuny-navigation.el create mode 100644 emacs/custom/fcuny-org.el create mode 100644 emacs/custom/fcuny-prog.el create mode 100644 emacs/custom/fcuny-settings.el create mode 100644 emacs/custom/fcuny-text.el create mode 100644 emacs/custom/fcuny-twitter.el create mode 100644 emacs/custom/fcuny-ui.el create mode 100644 emacs/custom/fcuny-vars.el create mode 100644 emacs/etc/elfeed.org create mode 100644 emacs/etc/interview.org create mode 100644 emacs/etc/new-project.org create mode 100644 emacs/etc/weekly_review.org create mode 100644 emacs/init.el create mode 100644 emacs/lisp/fcuny-commands.el create mode 100644 emacs/lisp/fcuny-flycheck-py.el (limited to 'emacs') diff --git a/emacs/custom/fcuny-conf.el b/emacs/custom/fcuny-conf.el new file mode 100644 index 0000000..97d1d1f --- /dev/null +++ b/emacs/custom/fcuny-conf.el @@ -0,0 +1,32 @@ +(use-package dockerfile-mode + :ensure t + :mode "Dockerfile[a-zA-Z.-]*\\'") + +(use-package yaml-mode + ;; At Twitter, we use PROJECT files to define a project and the + ;; format is YAML + :mode (("PROJECT" . yaml-mode)) + :ensure t) + +(use-package js-mode + :custom + (json-reformat:indent-width 2) + (js-indent-level 2) + :hook ((json-mode . flyspell-prog-mode) + (json-mode . flycheck-mode)) + :init + (if (fcuny/check-work-machine-p) + (add-to-list 'auto-mode-alist '("\\.workflow$" . js-mode)))) + +(use-package jq-format + :ensure t) + +(use-package protobuf-mode + :ensure t + :hook ((protobuf-mode . flyspell-prog-mode) + (protobuf-mode . flycheck-mode))) + +(use-package systemd + :ensure t) + +(provide 'fcuny-conf) diff --git a/emacs/custom/fcuny-defuns.el b/emacs/custom/fcuny-defuns.el new file mode 100644 index 0000000..48a9d97 --- /dev/null +++ b/emacs/custom/fcuny-defuns.el @@ -0,0 +1,55 @@ +(defun fcuny/remove-mysql-columns () + "Removes from text. This is useful when I want to drop the column separator from some text coming from a mysql query." + (interactive) + (while (search-forward-regexp "\s?|\s?") + (replace-match " "))) + +(defun fcuny/copy-whole-buffer () + "Selects the buffer and copy it." + (interactive) + (save-excursion + (mark-whole-buffer) + (copy-region-as-kill 1 (buffer-size)))) + +(defun fcuny/check-work-machine-p () + "Returns t if this is a work machine" + (string-match "tw-mbp.*" (system-name))) + +(defun fcuny/build-python-checker () + "Compiles a newer version of the checker for Python." + (interactive) + (let ((output (make-temp-file "checker-foo")) + (errors (make-temp-file "checker-errors")) + (default-directory "~/workspace/source")) + (let ((status (call-process "~/workspace/source/pants" nil `(,output ,errors) nil "-q" "binary" "src/python/twitter/devprod/checkstyle:check"))) + (if (zerop status) + (message "Built check.pex successfully") + (message (buffer-file-name output)))))) + +;; from https://karl-voit.at/2014/08/10/bookmarks-with-orgmode/ +(defun fcuny/string-replace (this withthat in) + "replace THIS with WITHTHAT' in the string IN" + (with-temp-buffer + (insert in) + (goto-char (point-min)) + (replace-string this withthat) + (buffer-substring (point-min) (point-max)))) + +(defun fcuny/get-page-title (url) + "Make URL into an org-mode link." + (let ((title)) + (with-current-buffer (url-retrieve-synchronously url) + (goto-char (point-min)) + (re-search-forward "\\([^<]*\\)" nil t 1) + (setq title (match-string 1)) + (goto-char (point-min)) + (re-search-forward "charset=\\([-0-9a-zA-Z]*\\)" nil t 1) + (fcuny/string-replace " " " " + ;;(decode-coding-string title (intern (match-string 1))) + ;; following line fixes charset issues from + ;; previous line: + (decode-coding-string title 'utf-8)) + (concat "[[" url "][" title "]]")))) + + +(provide 'fcuny-defuns) diff --git a/emacs/custom/fcuny-edit.el b/emacs/custom/fcuny-edit.el new file mode 100644 index 0000000..8ca5214 --- /dev/null +++ b/emacs/custom/fcuny-edit.el @@ -0,0 +1,39 @@ +(use-package autorevert + :config + (setq global-auto-revert-non-file-buffers t) + (setq auto-revert-verbose nil) + (global-auto-revert-mode t)) + +(use-package whitespace + :hook ((prog-mode . fcuny/whitespace-setup) + (conf-mode . fcuny/whitespace-setup) + (outline-mode . fcuny/whitespace-setup) + (yaml-mode . fcuny/whitespace-setup)) + + :custom + (whitespace-style '(face)) + (show-trailing-whitespace nil) + + :init + (defun fcuny/whitespace-setup () + (setq show-trailing-whitespace t))) + +(use-package electric-pair-mode + :commands electric-pair-mode + :hook (prog-mode . electric-pair-mode)) + +(use-package paren + :ensure t + :custom + (show-paren-delay 0) + (show-paren-when-point-inside-paren t) + (show-paren-when-point-in-periphery t) + :config + (show-paren-mode 1)) + +(global-set-key (kbd "M-j") 'join-line) + +;; don't assume that sentences should have two spaces after period. +(setq sentence-end-double-space nil) + +(provide 'fcuny-edit) diff --git a/emacs/custom/fcuny-eshell.el b/emacs/custom/fcuny-eshell.el new file mode 100644 index 0000000..113964c --- /dev/null +++ b/emacs/custom/fcuny-eshell.el @@ -0,0 +1,39 @@ +(use-package eshell + :hook (eshell-mode . fcuny/eshell-mode-setup) + + :custom + (eshell-scroll-to-bottom-on-input 'all) + (eshell-error-if-no-glob t) + (eshell-hist-ignoredups t) + (eshell-save-history-on-exit t) + (eshell-prefer-lisp-functions nil) + (eshell-destroy-buffer-when-process-dies t) + + :init + (defun fcuny/eshell-mode-setup () + (eshell/alias "e" "find-file $1") + (eshell/alias "emacs" "find-file $1") + (eshell/alias "ee" "find-file-other-window $1") + + (eshell/alias "gs" "magit-status") + (eshell/alias "gd" "magit-diff-unstaged") + (eshell/alias "gds" "magit-diff-staged") + (eshell/alias "d" "dired $1")) + + (defun eshell/gst (&rest args) + (magit-status (pop args) nil) + (eshell/echo)) ;; The echo command suppresses output + + (defun fcuny/eshell-here () + "Opens up a new shell in the directory associated with the current +buffer's file. The eshell is renamed to match that directory to make +multiple eshell windows easier." + (interactive) + (let* ((height (/ (window-total-height) 3))) + (split-window-vertically (- height)) + (other-window 1) + (eshell "new") + (insert (concat "ls")) + (eshell-send-input)))) + +(provide 'fcuny-eshell) diff --git a/emacs/custom/fcuny-flycheck.el b/emacs/custom/fcuny-flycheck.el new file mode 100644 index 0000000..e1805b2 --- /dev/null +++ b/emacs/custom/fcuny-flycheck.el @@ -0,0 +1,27 @@ +(eval-when-compile + (require 'use-package) + (require 'fcuny-flycheck-py)) + +(use-package flycheck + :ensure t + :hook (prog-mode . flycheck-mode ) + :custom + (flycheck-idle-change-delay 2) + (flycheck-emacs-lisp-load-path 'inherit) + (flycheck-highlighting-mode 'lines) + (flycheck-check-syntax-automatically '(mode-enabled save)) + (flycheck-disabled-checkers '(emacs-lisp-checkdoc)) + :config + (progn + (flycheck-define-checker fcuny/source-check-python + "A syntax checker for python source code in Source, using `check.pex'" + :command ("check.pex" source) + ;;; errors are reported like this: + ;;; E241:ERROR : + :error-patterns ((error line-start (id (1+ nonl)) ":ERROR" (1+ nonl) ":" line (message) line-end) + (warning line-start (id (1+ nonl)) ":WARNING" (1+ nonl) ":" line (message) line-end)) + :predicate fcuny/check-source-predicate-python-p + :modes (python-mode)) + (add-to-list 'flycheck-checkers 'fcuny/source-check-python))) + +(provide 'fcuny-flycheck) diff --git a/emacs/custom/fcuny-git.el b/emacs/custom/fcuny-git.el new file mode 100644 index 0000000..e3b8c45 --- /dev/null +++ b/emacs/custom/fcuny-git.el @@ -0,0 +1,76 @@ +(require 'fcuny-defuns) + +(use-package gitconfig-mode + :ensure t) + +(use-package gitattributes-mode + :ensure t) + +(use-package gitignore-mode + :ensure t) + +(use-package magit + :ensure t + :after (flyspell) + :bind (("C-x g" . magit-status)) + :custom + (vc-follow-symlinks t)) + +(use-package git-commit + :ensure t + :after magit + :hook (git-commit-mode . fcuny/git-commit-auto-fill) + :custom + (git-commit-summary-max-length 50) + :preface + (defun fcuny/git-commit-auto-fill () + "Ensures that the commit body does not exceed 72 characters." + (setq-local fill-column 72) + (setq-local comment-auto-fill-only-comments nil))) + +;; from https://sideshowcoder.com/2020/07/02/opening-sourcegraph-from-emacs/ +;; in a repo, add the following in .git/config: +;; +;; [git-link] +;; remote = mysourcegraph.sourcegraph +;; [remote "mysourcegraph.sourcegraph"] +;; url = https://sourcegraph.twitter.biz/gitpuppet.twitter.biz/puppet-twitter +;; +(use-package git-link + :ensure t + :config + (defun git-link-sourcegraph (hostname dirname filename _branch commit start end) + (let ((line-or-range (if end (format "%s-%s" start end) start))) + (format "https://%s/%s@%s/-/blob/%s#L%s" + hostname + dirname + commit + filename + line-or-range))) + + (defun git-link-commit-sourcegraph (hostname dirname commit) + (format "https://%s/%s/-/commit/%s" + hostname + dirname + commit)) + + (add-to-list 'git-link-remote-alist '("sourcegraph" git-link-sourcegraph)) + (add-to-list 'git-link-commit-remote-alist '("sourcegraph" git-link-commit-sourcegraph)) + + (setq git-link-open-in-browser 't)) + +;; https://magit.vc/manual/magit/Per_002dRepository-Configuration.html +;; we don't want to refresh buffers in source. This should help with +;; performances. +(dir-locals-set-class-variables 'huge-git-repository + '((nil . ((magit-refresh-buffers . nil))))) + +(dir-locals-set-directory-class + "/Users/fcuny/workspace/source" 'huge-git-repository) + +;; https://magit.vc/manual/magit/Performance.html +;; disable Git from the VC mode, since we use magit. This should help +;; with performances. +(setq vc-handled-backends (delq 'Git vc-handled-backends)) + +(provide 'fcuny-git) diff --git a/emacs/custom/fcuny-navigation.el b/emacs/custom/fcuny-navigation.el new file mode 100644 index 0000000..49309a5 --- /dev/null +++ b/emacs/custom/fcuny-navigation.el @@ -0,0 +1,128 @@ +(require 'fcuny-vars) + +(use-package bookmark + :custom + (bookmark-default-file (expand-file-name "bookmarks" fcuny/path-emacs-var)) + (bookmark-save-flag 1)) + +(use-package ls-lisp + :ensure nil + :custom + (ls-lisp-use-insert-directory-program nil) + (ls-lisp-dirs-first t)) + +(use-package dired + :defer t + :bind (("C-x C-d" . dired) + ("C-x C-j" . dired-jump)) + :init + (setq-default dired-dwim-target t) + (setq-default dired-listing-switches "-alh") + (setq dired-recursive-deletes 'always) + (setq dired-recursive-copies 'always)) + +(use-package dired-x + :ensure nil + :config + (progn + (setq dired-omit-verbose nil) + ;; hide backup, autosave, *.*~ files + ;; omit mode can be toggled using `C-x M-o' in dired buffer. + (add-hook 'dired-mode-hook #'dired-omit-mode) + (setq dired-omit-files + (concat dired-omit-files "\\|^.DS_Store$\\|^.localized$\\|^.projectile$\\|^.git$")))) + +(use-package ibuffer + :bind ("C-x C-b" . ibuffer) + :custom + (ibuffer-saved-filter-groups + (quote (("default" + ("org" (mode . org-mode)) + ("go" (mode . go-mode)) + ("python" (mode . python-mode)) + ("config" (or + (name . "\\.conf$") + (name . "\\.json$") + (mode . yaml-mode))) + ("puppet" (or + (mode . "\\.erb$") + (mode . puppet-mode))) + ("scripts" (mode . sh-mode)) + ("documentation" (or + (mode . markdown-mode) + (mode . rst-mode))) + ("dired" (mode . dired-mode)) + ("Emacs" (or + (mode . emacs-lisp-mode) + (name . "^\\*scratch\\*$") + (name . "^\\.emacs") + (name . "^\\*Messages\\*$"))))))) + :init + (add-hook 'ibuffer-mode-hook (lambda () (ibuffer-switch-to-saved-filter-groups "default")))) + +(use-package recentf + :init (recentf-mode 1) + :config + (add-to-list 'recentf-exclude "\\.emacs.d") + (add-to-list 'recentf-exclude ".+tmp......\\.org") + (setq recentf-max-saved-items 500 + recentf-save-file (expand-file-name "var/recentf" user-emacs-directory))) + +(use-package rg + :ensure t + :custom + (rg-group-result t) + (rg-show-columns t) + (rg-align-position-numbers t) + (rg-align-line-number-field-length 3) + (rg-align-column-number-field-length 3) + (rg-align-line-column-separator "#") + (rg-align-position-content-separator "|")) + +(use-package counsel + :diminish counsel-mode + :ensure t + :after ivy + :init (counsel-mode 1) + :bind + (("M-x" . counsel-M-x) + ("C-x C-f" . counsel-find-file) + ("C-x C-r" . counsel-recentf) + ("C-c i " . counsel-imenu) + ("C-c f" . counsel-git) + ("C-c /" . counsel-rg) + ("C-x r l" . counsel-bookmark)) + :custom + (counsel-find-file-ignore-regexp "\\.git\\|\\.DS_Store\\|\\.localized\\'") + (counsel-find-file-at-point t)) + +(use-package ivy + :ensure t + :diminish ivy-mode + :init (ivy-mode 1) + :custom + (ivy-use-virtual-buffers t) + (ivy-count-format "(%d/%d) ") + (ivy-height 20) + (ivy-use-selectable-prompt t) + :bind (("C-x b" . ivy-switch-buffer) + ("C-s" . swiper))) + +(use-package ivy-rich + :ensure t + :after (ivy) + :config + (ivy-rich-mode 1) + :custom + (ivy-extra-directories '("../" "./")) + (ivy-virtual-abbreviate 'full) + (ivy-rich-switch-buffer-align-virtual-buffer t) + (ivy-rich-path-style 'abbrev)) + +(use-package which-key + :diminish which-key-mode + :ensure t + :config + (which-key-mode)) + +(provide 'fcuny-navigation) diff --git a/emacs/custom/fcuny-org.el b/emacs/custom/fcuny-org.el new file mode 100644 index 0000000..92e0e65 --- /dev/null +++ b/emacs/custom/fcuny-org.el @@ -0,0 +1,113 @@ +(require 'fcuny-vars) + +(use-package htmlize + :ensure t) + +(use-package org + :ensure t + :mode (("\\.txt\\'" . org-mode)) + :hook ((org-mode . org-indent-mode) + (org-mode . org-hide-block-all) + (org-mode . visual-line-mode) + (org-capture-after-finalize . org-save-all-org-buffers) + (org-capture-prepare-finalize . org-save-all-org-buffers)) + :bind (("C-c c" . org-capture) + ("C-c a" . org-agenda)) + + :config + (defvar load-language-list '((emacs-lisp . t) + (python . t) + (shell . t))) + (use-package ob-go + :ensure t + :init (cl-pushnew '(go . t) load-language-list)) + + (org-babel-do-load-languages 'org-babel-load-languages + load-language-list) + + :custom + (org-id-locations-file (concat fcuny/path-emacs-var "/org-id-locations")) + + (org-directory (expand-file-name "~/Documents/Notebooks")) + (org-default-inbox-file (concat org-directory "/inbox.org")) + (org-default-notes-file (concat org-directory "/notes.org")) + (org-default-habit-file (concat org-directory "/habits.org")) + (org-default-tasks-file (concat org-directory "/personal-tasks.org")) + (org-default-work-tasks-file (concat org-directory "/work-tasks.org")) + (org-default-journal-file (concat org-directory "/personal-journal.org")) + (org-default-work-journal-file (concat org-directory "/work-journal.org")) + (org-default-interview-file (concat org-directory "/interviews.org")) + + ;; when archiving, inherit the tags from the parent + (org-archive-subtree-add-inherited-tags t) + + ;; display unicode characters + (org-pretty-entities t) + + ;; log the time of completion + (org-log-done 'time) + + ;; priorities + (org-priority-start-cycle-with-default nil) ;; Start one over/under default value. + (org-lowest-priority ?F) + (org-default-priority ?D) ;; Ensures unset tasks have low priority. + + ;; agenda related + (calendar-week-start-day 1) ;; org-mode uses calendar for the date picker, and I want this to start on Monday + (org-agenda-start-on-weekday 1) ;; this is specific to org-agenda + (org-agenda-files `(,org-default-tasks-file + ,org-default-work-tasks-file + ,org-default-habit-file)) + + ;; org babel related + ;; prevent the conversion of spaces into tabs (necessary for Python code exports) + (org-src-fontify-natively t) + (org-src-preserve-indentation t) + (org-edit-src-content-indentation t) + + ;; I want to follow links on RET + (org-return-follows-link t) + + ;; some configurations for exporting document + (org-export-with-toc nil) + (org-export-with-section-numbers nil) + + ;; A few abbreviations I use regularly + (org-link-abbrev-alist + '(("src" . "~/workspace/%s") + ("jira" . "https://jira.twitter.biz/browse/%s") + ("ph" . "https://phabricator.twitter.biz/%s") + ("go" . "http://go/%s"))) + + ;; entries + (org-blank-before-new-entry nil) + (org-blank-before-new-entry (quote ((heading . nil) + (plain-list-item . nil)))) + + ;; see https://github.com/abo-abo/swiper/issues/986 + (org-goto-interface 'outline-path-completion) + + (org-reverse-note-order t) + + (org-capture-templates + `(("t" "Todo [inbox]" entry + (file+headline ,org-default-inbox-file "Tasks") + "* TODO [#D] %?\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n") + + ("n" "Note" entry + (file ,org-default-notes-file) + "* NOTE %?\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n") + + ("j" "Journal" entry + (file+olp+datetree ,org-default-journal-file) + "* %?\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n" :tree-type month) + + ("i" "Interview notes" entry + (file+olp+datetree ,org-default-interview-file) + (file ,(concat fcuny/path-emacs-etc "/interview.org"))) + + ("J" "Work Journal" entry + (file+olp+datetree ,org-default-work-journal-file) + "* %?\n:PROPERTIES:\n:ID: %(shell-command-to-string \"uuidgen\"):CREATED: %U\n:END:\n" :tree-type month)))) + +(provide 'fcuny-org) diff --git a/emacs/custom/fcuny-prog.el b/emacs/custom/fcuny-prog.el new file mode 100644 index 0000000..9717df0 --- /dev/null +++ b/emacs/custom/fcuny-prog.el @@ -0,0 +1,99 @@ +(require 'fcuny-vars) + +(use-package auto-fill + :hook (prog-mode . auto-fill-mode) + :custom + ;; this does not seem to work .. + (comment-fill-column 80) + (comment-auto-fill-only-comments t)) + +(use-package company + :ensure t + :diminish company-mode + :custom + (company-minimum-prefix-length 2) + (company-tooltip-align-annotations t) + (company-tooltip-limit 12) + (company-idle-delay 1)) + +(use-package lsp-mode + :ensure t + :commands (lsp lsp-deferred) + :diminish lsp-mode + :hook (((go-mode) . lsp-deferred) + (lsp-mode . (lambda() (let ((lsp-keymap-prefix "C-c l")) + (lsp-enable-which-key-integration))))) + :config + (define-key lsp-mode-map (kbd "C-c l") lsp-command-map) + :bind + (("C-c l i" . lsp-ui-imenu)) + :custom + (lsp-session-file (expand-file-name "lsp-session-v1" fcuny/path-emacs-var)) + (lsp-enable-snippet t) + (lsp-signature-doc-lines 5) + (lsp-modeline-diagnostic-scope :workspace) + (lsp-completion-provider :capf) + (lsp-completion-enable t) + (lsp-enable-indentation t) + (lsp-prefer-flymake nil)) + +(use-package lsp-ui + :ensure t + :hook (lsp-mode . lsp-ui-mode) + :commands lsp-ui-mode + :custom + (lsp-ui-doc-delay 0.4) + (lsp-ui-doc-enable t) + (lsp-ui-doc-position 'top) + (lsp-ui-doc-include-signature t) + (lsp-ui-peek-enable t) + (lsp-ui-sideline-enable t) + (lsp-ui-imenu-enable t) + (lsp-ui-flycheck-enable t)) + +(use-package lsp-ivy + :ensure t + :commands lsp-ivy-workspace-symbol) + +(use-package sh-script + :mode ("bashrc" . sh-mode) + :hook (after-save . executable-make-buffer-file-executable-if-script-p) + :config + (setq-default sh-indentation 2 + sh-basic-offset 2)) + +(use-package python + :mode (("\\.py$" . python-mode) + ("\\.aurora$" . python-mode)) + :commands python-mode + :hook ((python-mode . eldoc-mode)) + :custom (python-indent-offset 2)) + +(use-package make-mode + :config + (add-hook 'makefile-mode-hook (lambda () (setq-local tab-width 2)))) + +(use-package go-mode + :ensure t + :hook ((before-save . lsp-format-buffer) + (before-save . lsp-organize-imports)) + :config + (when (memq window-system '(mac ns)) + (exec-path-from-shell-copy-env "GOPATH")) + :custom + (tab-width 4)) + +(use-package gotest + :ensure t) + +(use-package lisp-mode + :bind + (("C-c C-e" . eval-buffer) + ("C-c C-r" . eval-region))) + +(use-package puppet-mode + :ensure t + :bind (:map puppet-mode-map + ("C-c |" . puppet-align-block))) + +(provide 'fcuny-prog) diff --git a/emacs/custom/fcuny-settings.el b/emacs/custom/fcuny-settings.el new file mode 100644 index 0000000..a5ecc87 --- /dev/null +++ b/emacs/custom/fcuny-settings.el @@ -0,0 +1,56 @@ +(require 'fcuny-vars) + +;; set utf-8 as the default encoding +(prefer-coding-system 'utf-8-unix) +(setq locale-coding-system 'utf-8) +(set-language-environment 'utf-8) +(set-terminal-coding-system 'utf-8) +(set-keyboard-coding-system 'utf-8) + +;; alias yes-or-no to y-or-n +(fset 'yes-or-no-p 'y-or-n-p) + +(setq auto-save-default nil) ;; don't auto save files +(setq auto-save-list-file-prefix nil) ;; no backups +(setq create-lockfiles nil) ;; don't use a lock file +(setq custom-file fcuny/custom-settings) ;; where to save custom settings +(setq make-backup-files nil) ;; really no backups +(setq minibuffer-message-timeout 0.5) ;; How long to display an echo-area message +(setq next-screen-context-lines 5) ;; scroll 5 lines at a time +(setq require-final-newline t) ;; ensure newline exists at the end of the file +(setq ring-bell-function 'ignore) ;; really no bell +(setq tab-always-indent 'complete) ;; when using TAB, always indent +(setq visible-bell nil) ;; no bell +(setq column-number-mode t) ;; show column number in the mode line +(setq-default indent-tabs-mode nil) ;; turn off tab indentation +(setq-default cursor-type 'hbar) ;; cursor is a horizontal bar +(setq vc-handled-backends nil) ;; don't use the VC backend, it's too slow with source +(setq-default delete-by-moving-to-trash t) ;; delete files by moving them to the trash +(setq initial-scratch-message "") ;; empty scratch buffer + +(custom-set-variables + '(use-file-dialog nil) + '(use-dialog-box nil) + '(inhibit-startup-screen t) + '(inhibit-startup-message t) + '(inhibit-startup-echo-area-message t)) + +(setq user-full-name "franck cuny" + user-mail-address "franck@fcuny.net" + add-log-mailing-address "franck@fcuny.net") + +(use-package midnight + :config + (midnight-mode t)) + +(use-package server + :hook (after-init . server-start)) + +(use-package exec-path-from-shell + :ensure t + :init (exec-path-from-shell-initialize) + (when (memq window-system '(mac ns)) + (exec-path-from-shell-initialize)) + (exec-path-from-shell-copy-env "GOPATH")) + +(provide 'fcuny-settings) diff --git a/emacs/custom/fcuny-text.el b/emacs/custom/fcuny-text.el new file mode 100644 index 0000000..45198a1 --- /dev/null +++ b/emacs/custom/fcuny-text.el @@ -0,0 +1,31 @@ +(use-package flyspell + :ensure t + :if (executable-find "aspell") + :hook ((text-mode . flyspell-mode) + (prog-mode . flyspell-prog-mode)) + :custom + (ispell-dictionary "en_US") + (ispell-program-name "aspell") + :config + (use-package flyspell-correct-ivy + :after flyspell + :ensure t + :bind (:map flyspell-mode-map + ("C-M-:" . flyspell-correct-at-point)) + :custom + (flyspell-correct-interface #'flyspell-correct-ivy))) + +(use-package markdown-mode + :ensure t + :after (flyspell) + :commands (markdown-mode gfm-mode) + :mode (("README\\.md\\'" . gfm-mode) + ("\\.md\\'" . gfm-mode) + ("\\.markdown\\'" . gfm-mode)) + :custom + (markdown-fontify-code-blocks-natively t) + :config + (when (executable-find "pandoc") + (setq markdown-command "pandoc -f markdown -t html"))) + +(provide 'fcuny-text) diff --git a/emacs/custom/fcuny-twitter.el b/emacs/custom/fcuny-twitter.el new file mode 100644 index 0000000..ea3e424 --- /dev/null +++ b/emacs/custom/fcuny-twitter.el @@ -0,0 +1,13 @@ +(require 'fcuny-vars) + +(use-package pants + :load-path (lambda () (expand-file-name "pants.el" fcuny/path-workspace)) + :mode (("BUILD\\'" . pants-build-mode)) + :commands (pants-build-fmt pants-run-fmt pants-run-test pants-run-binary pants-run-python-repl) + :custom + (pants-completion-system 'ivy) + (pants-bury-compilation-buffer +1) + (pants-build-format-exec (expand-file-name "source/pants-support/buildifier/bin/buildifier" fcuny/path-workspace)) + (pants-source-tree-root (expand-file-name "source" fcuny/path-workspace))) + +(provide 'fcuny-twitter) diff --git a/emacs/custom/fcuny-ui.el b/emacs/custom/fcuny-ui.el new file mode 100644 index 0000000..5daef2e --- /dev/null +++ b/emacs/custom/fcuny-ui.el @@ -0,0 +1,83 @@ +(use-package fringe + :custom + (left-fringe-width 5) + (right-fringe-width 5)) + +(use-package scroll-bar + :config + (scroll-bar-mode -1)) + +(use-package tool-bar + :config + (tool-bar-mode -1)) + +(use-package menu-bar + :config + (menu-bar-mode -1)) + +(use-package modus-themes + :ensure t + :init + (use-package modus-operandi-theme) + (use-package modus-vivendi-theme) + :config (load-theme 'modus-operandi t) + :custom + (modus-themes-bold-constructs t) + (modus-themes-fringes nil) + (modus-themes-slanted-constructs t) + (modus-themes-mode-line '3d) + (modus-themes-syntax nil) + (Modus-themes-intense-hl-line nil) + (modus-themes-paren-match 'intense-bold) + (modus-themes-links 'neutral-underline) + (modus-themes-prompts 'subtle) + (modus-themes-completions nil) + (modus-themes-region 'bg-only-no-extend) + (modus-themes-diffs 'bg-only) + (modus-themes-variable-pitch-headings t) + (modus-themes-scale-headings t) + (modus-themes-scale-1 1.1) + (modus-themes-scale-2 1.15) + (modus-themes-scale-3 1.21) + (modus-themes-scale-4 1.27) + (modus-themes-scale-5 1.33)) + +(use-package diminish + :ensure t) + +(use-package frame + :config + (blink-cursor-mode -1) + (setq frame-title-format "%b") + (when (memq window-system '(mac ns)) + (set-frame-font "Source Code Pro-14") + (add-to-list 'default-frame-alist '(fullscreen . maximized)) + (add-to-list 'default-frame-alist '(ns-appearance . nil)) + (add-to-list 'default-frame-alist '(ns-transparent-titlebar . nil)) + (setq ns-use-native-fullscreen nil) + (setq mac-allow-anti-aliasing t)) + (when (memq window-system '(x)) + (set-frame-font "Source Code Pro-11") + ;; this is a fall back in the case we have unicode characeters. + ;; For example, with this settings, the following source is + ;; rendered correctly 😇 😀 and 🤢 + (set-fontset-font "fontset-default" nil + (font-spec :name "Noto Color Emoji")))) + +(use-package hl-line + :hook ((prog-mode text-mode conf-mode special-mode) . hl-line-mode) + :custom + ;; Not having to render the hl-line overlay in multiple buffers offers a tiny + ;; performance boost. I also don't need to see it in other buffers. + (hl-line-sticky-flag nil) + (global-hl-line-sticky-flag nil)) + +(use-package uniquify + :defer 5 + :config + ;; don't muck with special buffers + (setq uniquify-ignore-buffers-re "^\\*") + (setq uniquify-buffer-name-style 'forward) + (setq uniquify-separator "/")) + +(provide 'fcuny-ui) diff --git a/emacs/custom/fcuny-vars.el b/emacs/custom/fcuny-vars.el new file mode 100644 index 0000000..f3efe6a --- /dev/null +++ b/emacs/custom/fcuny-vars.el @@ -0,0 +1,16 @@ +(defvar fcuny/path-emacs-var (expand-file-name "var" user-emacs-directory) + "Path to some files for Emacs.") + +(defvar fcuny/path-emacs-etc (expand-file-name "etc" user-emacs-directory) + "Path to some files for Emacs.") + +(defvar fcuny/custom-settings (expand-file-name "emacs-custom.el" fcuny/path-emacs-var) + "Path to emacs custom variables.") + +(defvar fcuny/path-emacs-elpa (expand-file-name "elpa" fcuny/path-emacs-var) + "Path to elpa's local files.") + +(defvar fcuny/path-workspace (expand-file-name "workspace" (getenv "HOME")) + "Path to the workspace.") + +(provide 'fcuny-vars) diff --git a/emacs/etc/elfeed.org b/emacs/etc/elfeed.org new file mode 100644 index 0000000..900f615 --- /dev/null +++ b/emacs/etc/elfeed.org @@ -0,0 +1,36 @@ +#+TITLE: list of feeds + +* blogs :elfeed: +** [[https://apenwarr.ca/log/rss.php][apenwarr]] +** [[https://crawshaw.io/atom.xml][david crawshaw]] +** [[https://nullprogram.com/feed/][chris wellons]] +** [[https://vincent.bernat.ch/en/blog/atom.xml][vincent bernat]] +** [[https://www.tbray.org/ongoing/ongoing.atom][tim bray]] +** [[https://utcc.utoronto.ca/~cks/space/blog/?atom][chris siebenmann]] +** [[https://sachachua.com/blog/category/emacs/feed][sacha]] +** [[https://karl-voit.at/feeds/lazyblorg-all.atom_1.0.links-only.xml][karl voit]] +** [[http://endlessparentheses.com/atom.xml][endless parantheses]] +** [[https://trmm.net/api.php?hidebots=1&days=7&limit=50&action=feedrecentchanges&feedformat=atom][Trammel Hudson]] +** [[https://so.nwalsh.com/feed/fulltext.xml][Norman Walsh]] +** [[https://metebalci.com/index.xml][Mete Balci]] +** [[https://blog.thelifeofkenneth.com/feeds/posts/default][Kenneth]] +** [[http://fabiensanglard.net/rss.xml][Fabien Sanglard]] +** [[https://blog.acolyer.org/feed/][The Morning Paper]] +** [[https://www.unixsheikh.com/feed.rss][Unix Sheikh]] +** [[http://www.brendangregg.com/blog/rss.xm][Brendan Gregg]] +** [[http://www.masteringemacs.org/feed/][Mickey Petersen]] +** [[https://www.with-emacs.com/rss.xml][with emacs]] +** [[http://endlessparentheses.com/atom.xml][Endless Parentheses]] +** [[http://blog.fogus.me/feed/][Mike Fogus]] +** [[https://www.manueluberti.eu/feed.xml][Manuel Uberti]] +* aggregators :elfeed: +** [[https://lobste.rs/rss][lobste.rs]] +** [[https://news.ycombinator.com/rss][hacker news]] +** [[https://lwn.net/headlines/newrss][LWN]] +** [[https://undeadly.org/cgi?action=rss&full=on][undeadly]] +** [[http://planet.emacsen.org/atom.xml][planet emacsen]] +* sites :elfeed: +** [[https://usesthis.com/feed.atom][uses this]] +* companies :elfeed: +** [["https://oxide.computer/blog/index.xml][oxide]] +** [[https://research.fb.com/feed/][FB research]] diff --git a/emacs/etc/interview.org b/emacs/etc/interview.org new file mode 100644 index 0000000..dfb24b1 --- /dev/null +++ b/emacs/etc/interview.org @@ -0,0 +1,11 @@ +* %U %^{Candidate name} :interview: +:PROPERTIES: +:Created: %U +:PairingWith: %^{pairing with} +:Team: %^{which team} +:Position: %^{name of the position} +:END: +** Notes for the interview +** Feedback +** Concerns +** Outcome diff --git a/emacs/etc/new-project.org b/emacs/etc/new-project.org new file mode 100644 index 0000000..3d17d55 --- /dev/null +++ b/emacs/etc/new-project.org @@ -0,0 +1,15 @@ +* TODO %^{Project name} +DEADLINE: %^t +:PROPERTIES: +:STARTDATE: %u +:END: +%^{OUTCOME}p +%? +- [ ] Add project tags for context (e.g. work, personal) +- [ ] List specific tasks +- [ ] Schedule next actions from generated tasks +- [ ] Add links to wiki pages / tickets + +** Links +** Tasks +** Notes diff --git a/emacs/etc/weekly_review.org b/emacs/etc/weekly_review.org new file mode 100644 index 0000000..a7d2581 --- /dev/null +++ b/emacs/etc/weekly_review.org @@ -0,0 +1,40 @@ +* %U Review :review: +** Get Clear [0/3] +- [ ] Collect Loose Papers and Materials. +- [ ] Get "IN" to Zero: + - [ ] Papers + - [ ] Physical Notebook + - [ ] Physical Objects + - [ ] Text Messages + - [ ] Email Inbox + - [ ] [[https://read.amazon.com/kp/notebook][Kindle highlights]] + - [ ] Browser Tabs + - [ ] [[file:~/Downloads][Downloads]] Folder + - [ ] [[file:~/Desktop][Desktop]] Folder +- [ ] Empty Your Head: New projects, tasks, waiting-fors, someday/maybes? +** Get Current [0/7] +- [ ] Review Action Lists +#+BEGIN_SRC emacs-lisp + (progn + (org-agenda nil "a") + (org-agenda-day-view)) +#+END_SRC +- [ ] Archive completed or inactive projects +- [ ] Review calendar data +- [ ] Review Upcoming Calendar +- [ ] Review Waiting For List +- [ ] Review Project (and Larger Outcome) Lists +- [ ] Review Stuck Projects +- [ ] Review Any Relevant Checklists +** Get Creative [0/2] +- [ ] Review Someday Maybe List +- [ ] Be Creative and Courageous +** Journal +*** How are you doing right now? +*** What went well this week? +*** What didn't go so well this week? +*** Did I learn anything important this week? +*** Is there anything I can tweak, simplify, or eliminate? +*** What is currently holding me back? +*** What urgent questions do I have? +*** What do I feel grateful for in my life and work/school? diff --git a/emacs/init.el b/emacs/init.el new file mode 100644 index 0000000..6a9e142 --- /dev/null +++ b/emacs/init.el @@ -0,0 +1,41 @@ +;; Initialize the package system first of all. +(require 'package) + +(setq package-archives '(("melpa" . "https://melpa.org/packages/") + ("gnu" . "https://elpa.gnu.org/packages/"))) + +;; and now we load custom configurations +(add-to-list 'load-path (expand-file-name "custom" user-emacs-directory)) +(add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory)) + +(require 'fcuny-vars) + +;; where to store the packages +(setq package-user-dir fcuny/path-emacs-elpa) + +;; initialize it +(setq package-enable-at-startup nil) +(package-initialize) + +;; if use-package is not present, we install it +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) + +(require 'use-package) + +(require 'fcuny-commands) + +(require 'fcuny-settings) +(require 'fcuny-ui) +(require 'fcuny-defuns) +(require 'fcuny-navigation) +(require 'fcuny-edit) +(require 'fcuny-text) +(require 'fcuny-git) +(require 'fcuny-org) +(require 'fcuny-conf) +(require 'fcuny-flycheck) +(require 'fcuny-prog) +(require 'fcuny-eshell) +(require 'fcuny-twitter) diff --git a/emacs/lisp/fcuny-commands.el b/emacs/lisp/fcuny-commands.el new file mode 100644 index 0000000..a286e9f --- /dev/null +++ b/emacs/lisp/fcuny-commands.el @@ -0,0 +1,27 @@ +(defun rename-this-buffer-and-file () + "Renames current buffer and file it is visiting." + (interactive) + (let ((name (buffer-name)) + (filename (buffer-file-name)) + (read-file-name-function 'read-file-name-default)) + (if (not (and filename (file-exists-p filename))) + (error "Buffer '%s' is not visiting a file!" name) + (let ((new-name (read-file-name "New name: " filename))) + (cond ((get-buffer new-name) + (error "A buffer named '%s' already exists!" new-name)) + (t + (rename-file filename new-name 1) + (rename-buffer new-name) + (set-visited-file-name new-name) + (set-buffer-modified-p nil) + (message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name)))))))) + +(defun uniquify-region-lines (beg end) + "Remove duplicate adjacent lines in region." + (interactive "*r") + (save-excursion + (goto-char beg) + (while (re-search-forward "^\\(.*\n\\)\\1+" end t) + (replace-match "\\1")))) + +(provide 'fcuny-commands) diff --git a/emacs/lisp/fcuny-flycheck-py.el b/emacs/lisp/fcuny-flycheck-py.el new file mode 100644 index 0000000..68a5143 --- /dev/null +++ b/emacs/lisp/fcuny-flycheck-py.el @@ -0,0 +1,6 @@ +(defun fcuny/check-source-predicate-python-p () + (and (executable-find "check.pex") + (buffer-file-name) + (string-match "src/source/.*\.py$" (buffer-file-name)))) + +(provide 'fcuny-flycheck-py) -- cgit 1.4.1