diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2019-09-05 14:00:25 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2019-09-05 16:46:12 +0200 |
| commit | 99f78178964d12e3a8ae6cc4aebf894320e562df (patch) | |
| tree | 1c780d0b9d4740a41616ae716decbc469a102d8d | |
| parent | 0f3444ced75558884334a99fc04b9c72b1924e42 (diff) | |
| download | dotfiles-99f78178964d12e3a8ae6cc4aebf894320e562df.tar.gz dotfiles-99f78178964d12e3a8ae6cc4aebf894320e562df.zip | |
Added linters and polished code
The minimum version supported has been raised to 25.3.
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
| -rw-r--r-- | .emacs.d/.dir-locals.el | 3 | ||||
| -rw-r--r-- | .emacs.d/.gitignore | 5 | ||||
| -rw-r--r-- | .emacs.d/README.org | 2 | ||||
| -rw-r--r-- | .emacs.d/init.el | 35 | ||||
| -rw-r--r-- | .emacs.d/init.org | 20 | ||||
| -rw-r--r-- | .emacs.d/lisp/g.el | 36 | ||||
| -rwxr-xr-x | .emacs.d/test-emacs.sh | 51 | ||||
| -rwxr-xr-x | .emacs.d/test-startup.sh | 22 | ||||
| -rw-r--r-- | .irbrc | 22 | ||||
| -rw-r--r-- | .rubocop.yml | 3 | ||||
| -rw-r--r-- | .travis.yml | 21 | ||||
| -rwxr-xr-x | bin/json2yaml.rb | 1 | ||||
| -rwxr-xr-x | bin/test/test.sh | 4 | ||||
| -rwxr-xr-x | install.sh | 2 |
14 files changed, 163 insertions, 64 deletions
diff --git a/.emacs.d/.dir-locals.el b/.emacs.d/.dir-locals.el new file mode 100644 index 0000000..9c03a44 --- /dev/null +++ b/.emacs.d/.dir-locals.el @@ -0,0 +1,3 @@ +((emacs-lisp-mode + (fill-column . 100) + (indent-tabs-mode . nil))) diff --git a/.emacs.d/.gitignore b/.emacs.d/.gitignore index 3406897..e286c90 100644 --- a/.emacs.d/.gitignore +++ b/.emacs.d/.gitignore @@ -1,5 +1,10 @@ *.html +*.elc +*~ +*autoloads.el* lisp/*.elc +lisp/*autoloads.el* +vendor org-templates/*.pdf org-templates/*.tex org-templates/auto
\ No newline at end of file diff --git a/.emacs.d/README.org b/.emacs.d/README.org index 3cb3ccb..70ccec8 100644 --- a/.emacs.d/README.org +++ b/.emacs.d/README.org @@ -17,7 +17,7 @@ instructs =emacsclient= to spawn a new server if there isn't one already. This means that the first time around it will take some time, but in the next time everything will be alright. -=Supported versions=: GNU Emacs 25.x and 26.x. +=Supported versions=: GNU Emacs 25.3 and 26.x. * Dependencies diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 4129a5c..ccb4c35 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -1,7 +1,36 @@ +;;; init.el --- Init file -*- lexical-binding: t; -*- +;; +;; Copyright (C) 2016-2019 Miquel Sabaté Solà <mikisabate@gmail.com> +;; +;; Author: Miquel Sabaté Solà <mikisabate@gmail.com> +;; Version: 0.1 +;; Package-Requires: ((emacs "25.1")) +;; Keywords: local, maint, mail, tools, vc +;; URL: https://github.com/mssola/dotfiles/.emacs.d/init.el +;; +;; This file is not part of GNU Emacs. +;; +;; 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 3 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/>. +;; +;;; Commentary: +;; ;; This file replaces itself with the actual configuration at first run. ;; Idea and file taken from https://github.com/larstvei/dot-emacs. ;; -;; NOTE DO NOT MODIFY THIS FILE. All changes should go into init.org +;; NOTE DO NOT MODIFY THIS FILE. All changes should go into init.org. + +;;; Code: ;; We can't tangle without org! (require 'org) @@ -20,3 +49,7 @@ ;; Finally byte-compile it (byte-compile-file (concat user-emacs-directory "init.el")) + +(provide 'init) + +;;; init.el ends here diff --git a/.emacs.d/init.org b/.emacs.d/init.org index 13298c0..20552e9 100644 --- a/.emacs.d/init.org +++ b/.emacs.d/init.org @@ -68,7 +68,7 @@ are some exceptions to this (e.g. webkit support), but these cases are individually handled. #+BEGIN_SRC elisp -(let ((minver "25.1") +(let ((minver "25.3") (recver "26.1")) (when (version< emacs-version minver) (error "Don't be a cheap bastard and upgrade to at least GNU Emacs v%s" minver)) @@ -1294,9 +1294,7 @@ As of 0.9.18 and GNU Emacs 25, the =mu4e-action-with-xwidget= can be used to render an HTML message with Webkit. #+BEGIN_SRC elisp - (if (>= emacs-major-version 25) - (add-to-list 'mu4e-view-actions - '("webkit" . mu4e-action-view-with-xwidget))) +(add-to-list 'mu4e-view-actions '("webkit" . mu4e-action-view-with-xwidget)) #+END_SRC Look for =mu4e-msg2pdf= in the exec path. The reason for this is that the OBS @@ -2321,11 +2319,13 @@ too many things into my leader and these shortcuts look sensible to me). ** Screencast Some utilities when recording my GNU Emacs adventures. First of all, =keycast= -shows the keys being pressed in the mode line. +shows the keys being pressed in the mode line (it requires GNU Emacs 25.3 +minimum): #+BEGIN_SRC elisp (use-package keycast - :ensure t) + :ensure t + :unless (version< emacs-version "25.3")) #+END_SRC Second of all, we have =gif-screencast=, which allows you to record your GNU @@ -2334,6 +2334,7 @@ Emacs activity and saves it into a gif (unless you have specified the #+BEGIN_SRC elisp (use-package gif-screencast + :unless (version< emacs-version "25.3") :ensure t :config (with-eval-after-load 'gif-screencast @@ -2349,8 +2350,11 @@ And last but not least, I use a wrapper to start a screencast: (defun mssola-screencast () "Start keycast-mode and then start a gif screencast." - (keycast) - (gif-screencast)) + (if (version< emacs-version "25.3") + (message "Requires 25.3 or later.") + (progn + (keycast) + (gif-screencast)))) #+END_SRC ** Emojis diff --git a/.emacs.d/lisp/g.el b/.emacs.d/lisp/g.el index 3a4660a..fe842d8 100644 --- a/.emacs.d/lisp/g.el +++ b/.emacs.d/lisp/g.el @@ -1,7 +1,15 @@ -;;; g.el --- Adding shortcuts to GNU Emacs - +;;; g.el --- Adding shortcuts -*- lexical-binding: t; -*- +;; ;; Copyright (C) 2016-2019 Miquel Sabaté Solà <mikisabate@gmail.com> ;; +;; Author: Miquel Sabaté Solà <mikisabate@gmail.com> +;; Version: 0.1 +;; Package-Requires: ((emacs "25.1")) +;; Keywords: abbrev, convenience +;; URL: https://github.com/mssola/dotfiles/.emacs.d/lisp/g.el +;; +;; This file is not part of GNU Emacs. +;; ;; 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 3 of the License, or @@ -14,11 +22,7 @@ ;; ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see <http://www.gnu.org/licenses/>. - -;; Author: Miquel Sabaté Solà <mikisabate@gmail.com> -;; Version: 0.1 -;; URL: https://github.com/mssola/dotfiles/emacs/site-lisp/g.el - +;; ;;; Commentary: ;; ;; This is a GNU Emacs port of my g.sh bash script that can be found here: @@ -33,15 +37,15 @@ (defvar g-file "~/.gfile" "The path to the gfile.") -;; Utils +;;; Utils (defun g-read-file (file) "Read the given FILE and return it as a list of lines." (if (file-exists-p file) - (with-temp-buffer - (insert-file-contents file) - (split-string (buffer-string) "\n" t)) + (with-temp-buffer + (insert-file-contents file) + (split-string (buffer-string) "\n" t)) "")) (defun g-write (shortcuts) @@ -61,18 +65,18 @@ The returned object is a hash table." (let ((shortcuts (make-hash-table :test 'equal)) (list (g-read-file g-file))) - ; The format of the file is a bit special because it was meant to be easily - ; parseable by Bash. It consists of pairs of lines, where n is the key, and - ; n+1 is the value. + ;; The format of the file is a bit special because it was meant to be easily + ;; parseable by Bash. It consists of pairs of lines, where n is the key, and + ;; n+1 is the value. (dotimes (i (/ (length list) 2)) (let ((n (* i 2))) (puthash (nth n list) (nth (+ n 1) list) shortcuts))) - shortcuts)) + shortcuts)) -;; Interactive functions +;;; Interactive functions (defun g () "Go to the given directory with the supplied alias." diff --git a/.emacs.d/test-emacs.sh b/.emacs.d/test-emacs.sh new file mode 100755 index 0000000..14e47da --- /dev/null +++ b/.emacs.d/test-emacs.sh @@ -0,0 +1,51 @@ +#!/bin/bash -ex +# Some parts kindly taken from: https://github.com/purcell/emacs.d + +if [ -n "$TRAVIS" ]; then + # We still need to have an .emacs.d directory, so emacs-async (dependency of + # some other package) is happy. + export HOME=$PWD/.. + ln -s emacs ../.emacs.d +fi + +## +# Linters. + +mkdir -p vendor +wget -q -O vendor/elisp-lint.el https://raw.githubusercontent.com/gonewest818/elisp-lint/master/elisp-lint.el +wget -q -O vendor/package-lint.el https://raw.githubusercontent.com/purcell/package-lint/master/package-lint.el +LOAD_PATH="-L $(readlink -f -- vendor)" + +# shellcheck disable=SC2039 +pushd . +for i in . lisp; do + cd "$i" + # shellcheck disable=SC2010 + # shellcheck disable=SC2035 + files="$(ls *.el | grep -v 'custom.el' | grep -v 'lisp-autoloads.el' | grep -v '.emacs.d-autoloads.el' | grep -v 'soria-theme.el' | xargs)" + + # shellcheck disable=SC2086 + ${EMACS:=emacs} -Q --batch ${LOAD_PATH} -l elisp-lint.el -f elisp-lint-files-batch $files + # shellcheck disable=SC2086 + ${EMACS:=emacs} -Q --batch ${LOAD_PATH} -l package-lint.el -f package-lint-batch-and-exit $files +done + +# shellcheck disable=SC2039 +popd +rm -r vendor + +## +# Startup. + +echo "Attempting startup..." + +${EMACS:=emacs} -nw --batch \ + --eval '(let ((debug-on-error t) + (url-show-status nil) + (user-emacs-directory default-directory) + (package-user-dir (expand-file-name (concat "elpa-" emacs-version))) + (custom-theme-directory default-directory) + (user-init-file (expand-file-name "init.el"))) + (load-file user-init-file) + (run-hooks (quote after-init-hook)))' +echo "Startup successful" diff --git a/.emacs.d/test-startup.sh b/.emacs.d/test-startup.sh deleted file mode 100755 index d8f3547..0000000 --- a/.emacs.d/test-startup.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -ex -# Kindly taken from: https://github.com/purcell/emacs.d - -if [ -n "$TRAVIS" ]; then - # We still need to have an .emacs.d directory, so emacs-async (dependency of - # some other package) is happy. - export HOME=$PWD/.. - ln -s emacs ../.emacs.d -fi - -echo "Attempting startup..." - -${EMACS:=emacs} -nw --batch \ - --eval '(let ((debug-on-error t) - (url-show-status nil) - (user-emacs-directory default-directory) - (package-user-dir (expand-file-name (concat "elpa-" emacs-version))) - (custom-theme-directory default-directory) - (user-init-file (expand-file-name "init.el"))) - (load-file user-init-file) - (run-hooks (quote after-init-hook)))' -echo "Startup successful" @@ -1,8 +1,19 @@ -#!/usr/bin/env ruby -# -# Author: Miquel Sabaté -# http://github.com/mssola/dotfiles +# frozen_string_literal: true +# Copyright (C) 2014-2019 Miquel Sabaté Solà <mikisabate@gmail.com> +# +# 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 3 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/>. require 'irb/completion' require 'irb/ext/save-history' @@ -10,7 +21,6 @@ require 'rubygems' require 'pp' require 'wirble' - # Colorize! Wirble.init Wirble.colorize @@ -40,7 +50,7 @@ end # Beautify ls def ls - %x{ls}.split("\n") + `ls`.split("\n") end alias p pp diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..c0d6e89 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,3 @@ +# Allow me to write me own name on the copyright notice :) +Style/AsciiComments: + Enabled: false diff --git a/.travis.yml b/.travis.yml index 2e041e7..53afa2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ # The procedure for testing GNU Emacs was kindly taken from: # https://github.com/purcell/emacs.d +dist: trusty language: ruby before_install: @@ -10,9 +11,11 @@ before_install: # mu4e - sudo apt-get -qq update - sudo apt-get install -y maildir-utils + - pushd /tmp - wget https://github.com/djcb/mu/releases/download/v1.0/mu-1.0.tar.xz - tar xJvf mu-1.0.tar.xz - sudo cp -r mu-1.0/mu4e /usr/share/emacs/site-lisp/ + - popd - evm config path /tmp - evm install $EVM_EMACS --use --skip @@ -20,12 +23,14 @@ before_install: # shellcheck - sudo apt-get install -y shellcheck + # rubocop + - gem install rubocop + env: - - EVM_EMACS=emacs-25.1-travis - - EVM_EMACS=emacs-25.2-travis - EVM_EMACS=emacs-25.3-travis - EVM_EMACS=emacs-26.1-travis - - EVM_EMACS=emacs-26.2-travis + # GNU Emacs 26.2 refuses to work on Travis because of the bug on fetching + # elpa.gnu.org. It works locally for me. - EVM_EMACS=emacs-git-snapshot-travis matrix: @@ -35,14 +40,14 @@ matrix: script: # Testing GNU Emacs - git clone https://github.com/mssola/soria.git - - cp soria/soria-theme.el emacs/soria-theme.el - - lsb_release -a && cd emacs && ./test-startup.sh + - cp soria/soria-theme.el .emacs.d/soria-theme.el + - lsb_release -a && cd .emacs.d && ./test-emacs.sh # Testing scripts - cd ../bin/test && ./test.sh # Shellcheck - # TODO: don't skip stuff like bashrc and many others - - cd ../.. && find . -name "*.sh" ! -name "gitcompletion.sh" ! -name "hgcompletion.sh" -exec shellcheck \{\} \+ + - cd ../.. && find . -name "*.sh" ! -name ".gitcompletion.sh" ! -name ".hgcompletion.sh" -not -path "./.emacs.d/*" -exec shellcheck \{\} \+ - # TODO: linters for emacs, perl, ruby + # Ruby style + - rubocop diff --git a/bin/json2yaml.rb b/bin/json2yaml.rb index 4f77f8b..6239e8a 100755 --- a/bin/json2yaml.rb +++ b/bin/json2yaml.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require 'json' require 'yaml' diff --git a/bin/test/test.sh b/bin/test/test.sh index 666818a..20f9439 100755 --- a/bin/test/test.sh +++ b/bin/test/test.sh @@ -26,7 +26,7 @@ status=0 # license main.cpp $license "$dir/main.cpp" d=$(diff "$dir/main.cpp" "$dir/main.cpp.expected") -if [ ! -z "$d" ]; then +if [ -n "$d" ]; then echo "$d" status=1 fi @@ -34,7 +34,7 @@ fi # license README.md $license "$dir/README.md" d=$(diff "$dir/README.md" "$dir/README.md.expected") -if [ ! -z "$d" ]; then +if [ -n "$d" ]; then echo "$d" status=1 fi @@ -40,6 +40,8 @@ for i in "${ary[@]:1:${#ary[@]}}"; do ignore+=" -or -name $i" done +# shellcheck disable=SC2086 +# shellcheck disable=SC2044 for file in $(find "$(pwd)" -mindepth 1 -maxdepth 1 ! \( $ignore \)); do # The -F and -f flags of ln suck. Let's rm all the way. rm -rf "${HOME:?}/$(basename $file)" |
