From c049e6ef689e7bf5145dde9a80b4473eb637c3ad Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sun, 8 Jul 2018 14:33:02 +0000 Subject: [emacs] Reduce number of configuration files. Group settings in a sensible way. --- emacs.d/config/fcuny-appearance.el | 22 ----------- emacs.d/config/fcuny-base.el | 69 ++++++++++++++++++++++++++++++++++ emacs.d/config/fcuny-basic-settings.el | 15 ++++++++ emacs.d/config/fcuny-common.el | 29 -------------- emacs.d/config/fcuny-vars.el | 41 -------------------- emacs.d/init.el | 4 +- 6 files changed, 85 insertions(+), 95 deletions(-) delete mode 100644 emacs.d/config/fcuny-appearance.el create mode 100644 emacs.d/config/fcuny-base.el delete mode 100644 emacs.d/config/fcuny-common.el delete mode 100644 emacs.d/config/fcuny-vars.el diff --git a/emacs.d/config/fcuny-appearance.el b/emacs.d/config/fcuny-appearance.el deleted file mode 100644 index 5c65374..0000000 --- a/emacs.d/config/fcuny-appearance.el +++ /dev/null @@ -1,22 +0,0 @@ -(eval-when-compile - (require 'use-package)) - -;; Set default font. -(set-face-attribute 'default nil :height 130 :weight 'normal :width 'normal) - -(use-package tool-bar - :config - (tool-bar-mode -1)) - -(use-package scroll-bar - :config - (scroll-bar-mode -1)) - -(use-package frame - :bind ("" . toggle-frame-fullscreen) - :config - (blink-cursor-mode -1) - (when (eq system-type 'darwin) - (setq ns-use-native-fullscreen nil))) - -(provide 'fcuny-appearance) diff --git a/emacs.d/config/fcuny-base.el b/emacs.d/config/fcuny-base.el new file mode 100644 index 0000000..bca68c8 --- /dev/null +++ b/emacs.d/config/fcuny-base.el @@ -0,0 +1,69 @@ +(defvar fcuny-path-home (getenv "HOME") + "Path to the user's home directory.") + +(defvar fcuny-path-workspace (expand-file-name "workspace" fcuny-path-home) + "Path to the workspace.") + +(defvar fcuny-path-go (expand-file-name "go" fcuny-path-workspace) + "Path to GOPATH.") + +(defvar fcuny-path-go-bin (expand-file-name "bin" fcuny-path-go) + "Path to the go binaries.") + +(defvar fcuny-path-git-twitter (expand-file-name "git.twitter.biz" fcuny-path-workspace) + "Path to twitter's git repositories.") + +(defvar fcuny-path-git-github (expand-file-name "github.com" fcuny-path-workspace) + "Path to github's git repositories.") + +(defvar fcuny-path-svn-twitter (expand-file-name "svn.twitter.biz" fcuny-path-workspace) + "Path to twitter's SVN repositories.") + +(defvar fcuny-path-puppet-linter-svn (expand-file-name "twitter-ops/utilities/puppet/.puppet-lint.rc" + fcuny-path-svn-twitter) + "Path to the linter's configuration for twitter-ops.") + +(defvar fcuny-path-emacs-var (expand-file-name "var" user-emacs-directory) + "Path to some files for Emacs.") + +(defvar fcuny-path-emacs-elpa (expand-file-name "elpa" fcuny-path-emacs-var) + "Path to elpa's local files.") + +(defvar fcuny-projects-ignored-dirs '(".git" ".svn" "target" "elpa") + "Ignore the following directories when browsing with projectile.") + +(defvar fcuny-bookmarks-dir (expand-file-name "bookmarks" fcuny-path-emacs-var) + "Path to save the bookmarks") + +(defvar fcuny-custom-settings (expand-file-name "emacs-custom.el" fcuny-path-emacs-var) + "Path to emacs custom variables.") + +(defun fcuny-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 fc/check-work-machine-p () + "Returns t if this is a work machine" + (string-match "tw-mbp.*" (system-name))) + +(defun fc/check-source-p () + "Finds if the current python file is in the `source' repository." + (and (executable-find "check.pex") + (buffer-file-name) + (string-match "src/source/.*\.py$" (buffer-file-name)))) + +(provide 'fcuny-base) diff --git a/emacs.d/config/fcuny-basic-settings.el b/emacs.d/config/fcuny-basic-settings.el index fe05241..a3469a8 100644 --- a/emacs.d/config/fcuny-basic-settings.el +++ b/emacs.d/config/fcuny-basic-settings.el @@ -35,4 +35,19 @@ ;; Remap join-line to M-j where it's easier to get to. (global-set-key (kbd "M-j") 'join-line) +(use-package tool-bar + :config + (tool-bar-mode -1)) + +(use-package scroll-bar + :config + (scroll-bar-mode -1)) + +(use-package frame + :bind ("" . toggle-frame-fullscreen) + :config + (blink-cursor-mode -1) + (when (eq system-type 'darwin) + (setq ns-use-native-fullscreen nil))) + (provide 'fcuny-basic-settings) diff --git a/emacs.d/config/fcuny-common.el b/emacs.d/config/fcuny-common.el deleted file mode 100644 index 61a2829..0000000 --- a/emacs.d/config/fcuny-common.el +++ /dev/null @@ -1,29 +0,0 @@ -(defun fc/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 fc/check-source-p () - "Finds if the current python file is in the `source' repository." - (and (executable-find "check.pex") - (buffer-file-name) - (string-match "src/source/.*\.py$" (buffer-file-name)))) - -(defun fc/check-work-machine-p () - "Returns t if this is a work machine" - (string-match "tw-mbp.*" (system-name))) - -(provide 'fcuny-common) diff --git a/emacs.d/config/fcuny-vars.el b/emacs.d/config/fcuny-vars.el deleted file mode 100644 index aebaadf..0000000 --- a/emacs.d/config/fcuny-vars.el +++ /dev/null @@ -1,41 +0,0 @@ -(defvar fcuny-path-home (getenv "HOME") - "Path to the user's home directory.") - -(defvar fcuny-path-workspace (expand-file-name "workspace" fcuny-path-home) - "Path to the workspace.") - -(defvar fcuny-path-go (expand-file-name "go" fcuny-path-workspace) - "Path to GOPATH.") - -(defvar fcuny-path-go-bin (expand-file-name "bin" fcuny-path-go) - "Path to the go binaries.") - -(defvar fcuny-path-git-twitter (expand-file-name "git.twitter.biz" fcuny-path-workspace) - "Path to twitter's git repositories.") - -(defvar fcuny-path-git-github (expand-file-name "github.com" fcuny-path-workspace) - "Path to github's git repositories.") - -(defvar fcuny-path-svn-twitter (expand-file-name "svn.twitter.biz" fcuny-path-workspace) - "Path to twitter's SVN repositories.") - -(defvar fcuny-path-puppet-linter-svn (expand-file-name "twitter-ops/utilities/puppet/.puppet-lint.rc" - fcuny-path-svn-twitter) - "Path to the linter's configuration for twitter-ops.") - -(defvar fcuny-path-emacs-var (expand-file-name "var" user-emacs-directory) - "Path to some files for Emacs.") - -(defvar fcuny-path-emacs-elpa (expand-file-name "elpa" fcuny-path-emacs-var) - "Path to elpa's local files.") - -(defvar fcuny-projects-ignored-dirs '(".git" ".svn" "target" "elpa") - "Ignore the following directories when browsing with projectile.") - -(defvar fcuny-bookmarks-dir (expand-file-name "bookmarks" fcuny-path-emacs-var) - "Path to save the bookmarks") - -(defvar fcuny-custom-settings (expand-file-name "emacs-custom.el" fcuny-path-emacs-var) - "Path to emacs custom variables.") - -(provide 'fcuny-vars) diff --git a/emacs.d/init.el b/emacs.d/init.el index dd233a1..8ac9baf 100644 --- a/emacs.d/init.el +++ b/emacs.d/init.el @@ -26,10 +26,8 @@ (require 'use-package) -(use-package fcuny-vars) +(use-package fcuny-base) (use-package fcuny-basic-settings) -(use-package fcuny-common) -(use-package fcuny-appearance) (use-package fcuny-darwin :if (memq window-system '(mac ns))) -- cgit 1.4.1