emacs.d

My Emacs configuration files.
git clone git://soucy.cc/emacs.d.git
Log | Files | Refs | README

commit 787dbe9855fc878f309c01b0bbc8a671503c842c
parent 963d4f9f9bbc55fbc70df7effbea339c729186b7
Author: Hugo Soucy <hugo.soucy@equisoft.com>
Date:   Fri, 25 Oct 2019 10:41:51 -0400

Merge branch 'master' of github.com:hs0ucy/.emacs.d

Diffstat:
Mdefuns/duplicate-line.el | 47++++++++++++++++++++++++++++++++++-------------
Ddefuns/styled.el | 48------------------------------------------------
Mpartials/extras.el | 2+-
Mpartials/key-bindings.el | 4++--
Mpartials/org.el | 6+++---
Mpartials/ui-ux.el | 16+++++++++-------
Mpartials/webdev.el | 9+--------
Asnippets/css-mode/button | 34++++++++++++++++++++++++++++++++++
Asnippets/css-mode/visuallyhidden | 14++++++++++++++
Asnippets/web-mode/blocks/block-img-clickable | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asnippets/web-mode/buttons/button-link | 22++++++++++++++++++++++
Asnippets/web-mode/css-default | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Asnippets/web-mode/iframe-responsive | 33+++++++++++++++++++++++++++++++++
Asnippets/web-mode/locize-use-translation | 6++++++
14 files changed, 281 insertions(+), 82 deletions(-)

diff --git a/defuns/duplicate-line.el b/defuns/duplicate-line.el @@ -1,15 +1,36 @@ ;; Duplicating lines & commenting them -(defun djcb-duplicate-line (&optional commentfirst) - "comment line at point; if COMMENTFIRST is non-nil, comment the original" - (interactive) - (beginning-of-line) - (let - ((beg (point))) - (end-of-line) - (let ((str (buffer-substring beg (point)))) - (when commentfirst - (comment-region beg (point))) - (insert-string - (concat (if (= 0 (forward-line 1)) "" "\n") str "\n")) - (forward-line -1)))) +(defun duplicate-line (arg) + "Duplicate current line, leaving point in lower line." + (interactive "*p") + + ;; save the point for undo + (setq buffer-undo-list (cons (point) buffer-undo-list)) + + ;; local variables for start and end of line + (let ((bol (save-excursion (beginning-of-line) (point))) + eol) + (save-excursion + + ;; don't use forward-line for this, because you would have + ;; to check whether you are at the end of the buffer + (end-of-line) + (setq eol (point)) + + ;; store the line and disable the recording of undo information + (let ((line (buffer-substring bol eol)) + (buffer-undo-list t) + (count arg)) + ;; insert the line arg times + (while (> count 0) + (newline) ;; because there is no newline in 'line' + (insert line) + (setq count (1- count))) + ) + + ;; create the undo information + (setq buffer-undo-list (cons (cons eol (point)) buffer-undo-list))) + ) ; end-of-let + + ;; put the point in the lowest line and return + (next-line arg)) diff --git a/defuns/styled.el b/defuns/styled.el @@ -1,48 +0,0 @@ -;;; styled.el --- Styled components for emacs. -*- lexical-binding: t; -*- - -;; Copyright (C) 2018 Eduardo V. - -;;; Commentary: - -;;; Code: - -(require 'css-mode) -(require 'fence-edit) -(require 'rx) -(require 'ov) - -(setq - styled-component-start - (rx-to-string '(: (1+ (and (+ word) (0+ "\.") (0+ "(" (+ alpha) ")"))) "`" eol))) - -(setq styled-component-end (rx-to-string '(: "`;" eol))) - -(setq - styled-component-region - (rx-to-string '(: (minimal-match - (seq - (and (1+ (and (+ word) (0+ "\.") (0+ "(" (+ alpha) ")"))) "`") - (or "\n" "\r") - (0+ (+ any) (or "\n" "\r")) - (and "`;" eol)))))) - -(setq fence-edit-blocks `((,styled-component-start ,styled-component-end))) -(setq fence-edit-default-mode 'css-mode) - -(defun styled/get-component () - "Get current buffer styled components." - (interactive) - (let (matches match beg end) - (save-match-data - (save-excursion - (goto-char (point-min)) - (while (search-forward-regexp styled-component-region nil t 1) - (setq match (match-string-no-properties 0)) - (setq beg (match-beginning 0)) - (setq end (match-end 0)) - (push (list beg end match) matches)) - )) - (reverse matches))) - -(provide 'styled) -;;; styled.el ends here diff --git a/partials/extras.el b/partials/extras.el @@ -66,7 +66,7 @@ :ensure t :pin melpa :config - (setq mastodon-instance-url "https://mastodon.social")) + (setq mastodon-instance-url "https://mastodon.sdf.org")) (use-package dumb-jump ;; jump to definition for multiple languages without configuration. diff --git a/partials/key-bindings.el b/partials/key-bindings.el @@ -14,10 +14,10 @@ (global-set-key (kbd "C--") 'text-scale-decrease) ;; Duplicate a line -(global-set-key (kbd "M-RET") 'djcb-duplicate-line) +(global-set-key (kbd "M-RET") 'duplicate-line) ;; Duplicate a line and comment the first -(global-set-key (kbd "C-c y") (lambda()(interactive)(djcb-duplicate-line t))) +(global-set-key (kbd "C-c y") (lambda()(interactive)(duplicate-line t))) ;; Compress a few lines into one (global-set-key (kbd "M-é") 'top-join-line) diff --git a/partials/org.el b/partials/org.el @@ -9,14 +9,14 @@ ;; Org-mode settings (setq org-todo-keywords - '((sequence "TODO" "INPROGRESS" "REVIEW" "WAITING" "DELEGATED" "DONE"))) + '((sequence "TODO" "INPROGRESS" "STANBY" "REVIEW" "WAITING" "DELEGATED" "DONE"))) (setq org-agenda-files '("~/Nextcloud/Org")) (setq org-capture-templates '(("a" "My TODO task at WORK." entry (file "~/Nextcloud/Org/job.org") - "**** TODO %? \n SCHEDULED: %t DEADLINE: 0") + "*** TODO %? \n SCHEDULED: %t DEADLINE: 0") ("b" "My TODO task at HOME." entry (file "~/Nextcloud/Org/log.org") - "**** TODO %? \n SCHEDULED: %t DEADLINE: 0"))) + "*** TODO %? \n SCHEDULED: %t DEADLINE: 0"))) ;;; org.el ends here diff --git a/partials/ui-ux.el b/partials/ui-ux.el @@ -12,10 +12,10 @@ :config (which-key-mode)) -(use-package hexrgb - ;; Functions to manipulate colors, including RGB hex strings. - :ensure t - :pin marmalade) +;; (use-package hexrgb +;; ;; Functions to manipulate colors, including RGB hex strings. +;; :ensure t +;; :pin marmalade) (use-package ace-window ;; Quickly switch windows. @@ -27,9 +27,11 @@ ;; Fonts ;; Custom font face (120 === 12pt) -(if (not (eq system-type 'darwin)) - (set-face-attribute 'default nil :font "Terminus" :height 120) - (set-face-attribute 'default nil :height 140)) +;; (if (not (eq system-type 'darwin)) +;; (set-face-attribute 'default nil :font "Terminus" :height 120) +;; (set-face-attribute 'default nil :height 140)) +(set-face-attribute 'default nil :font "Fira Code" :height 120) +;; (set-face-attribute 'default nil :font "Ubuntu Mono" :height 120) ;; Ibuffer ;; By default Buffer List with Ibuffer diff --git a/partials/webdev.el b/partials/webdev.el @@ -32,6 +32,7 @@ (add-to-list 'auto-mode-alist '("\\.etlua\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.twig\\'" . web-mode)) (add-to-list 'auto-mode-alist '("\\.jsx\\'" . web-mode)) + (add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode)) (defadvice web-mode-highlight-part (around tweak-jsx activate) (if (equal web-mode-content-type "jsx") (let ((web-mode-enable-part-face nil)) @@ -64,12 +65,4 @@ :ensure t :pin gnu) -(use-package mmm-mode - ;; Allow Multiple Major Modes in a buffer - :ensure t - :pin gnu - :config - (setq mmm-global-mode 'maybe) - (mmm-add-mode-ext-class 'scss-mode "\\.jsx\\'" 'scss-jsx)) - ;;; webdev.el ends here diff --git a/snippets/css-mode/button b/snippets/css-mode/button @@ -0,0 +1,34 @@ +# -*- mode: snippet -*- +# name: Button Element +# key: button +# -- + +.button { + align-items: center; + appearance: none; + background: inherit; + border: 1px solid; + border-radius: 1.25rem; + box-sizing: border-box; + color: inherit; + display: inline-flex; + font-size: 0.75rem; + font-weight: 700; + letter-spacing: 0.025rem; + line-height: normal; + min-height: 2rem; + min-width: 2rem; + outline: none; + padding: 0.5rem 1rem; + text-transform: uppercase; + transition: all 0.2s ease-in-out; + user-select: none; + + &:not(:disabled) { + cursor: pointer; + } + + > svg { + color: inherit; + } +} diff --git a/snippets/css-mode/visuallyhidden b/snippets/css-mode/visuallyhidden @@ -0,0 +1,14 @@ +# -*- mode: snippet -*- +# name: Visually Hidden +# key: visuallyhidden +# -- + +.visuallyhidden { + border: 0 !important; + clip: rect(1px, 1px, 1px, 1px); + height: 1px !important; + overflow: hidden; + padding:0 !important; + position: absolute !important; + width: 1px !important; +} diff --git a/snippets/web-mode/blocks/block-img-clickable b/snippets/web-mode/blocks/block-img-clickable @@ -0,0 +1,70 @@ +# -*- mode: snippet -*- +# name: Clickable BLOCK with image & text (HTML/CSS) +# key: block-img-clickable +# -- + +<style> + .block-img-clickable { + color: #ffffff; + display: inline-block; + position: relative; + text-decoration: none; + } + + .block-img-clickable:focus { + outline: 0.5rem solid rgb(6, 80, 105); + outline-offset: -0.5rem; + } + + .block-img-clickable__text { + background: rgba(6, 80, 105, 0.75); + bottom: 0; + color: #ffffff; + font-size: 1rem; + font-weight: 700; + line-height: normal; + padding: 2rem 6rem 2rem 2rem; + margin: 0; + left: 0; + position: absolute; + right: 0; + transition: all 0.25s ease-in-out; + z-index: 1; + } + + .block-img-clickable:focus .block-img-clickable__text, + .block-img-clickable:hover .block-img-clickable__text { + background: rgba(6,80,105,1); + } + + .block-img-clickable__text::after { + background: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB2aWV3Qm94PSIwIDAgMTEgMTkiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8dGl0bGU+cGljdG8vbGluazwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxnIGlkPSJTeW1ib2xzIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPgogICAgICAgIDxnIGlkPSJCVE4tdm9pci10b3VzIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtOTUuMDAwMDAwLCAtNC4wMDAwMDApIiBzdHJva2U9IiNmZmZmZmYiIHN0cm9rZS13aWR0aD0iMyI+CiAgICAgICAgICAgIDxnIGlkPSJCVE4tRXZlbnRicml0ZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoOS4wMDAwMDAsIDAuMDAwMDAwKSI+CiAgICAgICAgICAgICAgICA8ZyBpZD0icGljdG8vbGluayIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoODIuMDAwMDAwLCAwLjAwMDAwMCkiPgogICAgICAgICAgICAgICAgICAgIDxwb2x5bGluZSBpZD0iUGFnZS0xIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSg5LjYwODA0OSwgMTMuMjE2MzUyKSByb3RhdGUoLTkwLjAwMDAwMCkgdHJhbnNsYXRlKC05LjYwODA0OSwgLTEzLjIxNjM1MikgIiBwb2ludHM9IjE3LjM1OTQzODQgOS40MjkwNTE5NiA5LjYwODA0ODYzIDE3LjAwMzY1MjQgMS44NTY2NTg4NiA5LjQyOTA1MTk2Ii8+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPgo=") no-repeat; + bottom: 0; + content: ""; + display: block; + height: 2rem; + margin: auto 0; + position: absolute; + right: 2rem; + top: 0; + width: 2rem; + } + + .block-img-clickable__img { + display: inline-block; + max-width: 100%; + vertical-align: bottom; + } +</style> + +<a class="block-img-clickable" href="${1:#}"> + <h2 class="block-img-clickable__text" id="txtImg0"> + ${3:Cum sociis natoque penatibus et magnis dis parturient montes, + nascetur ridiculus mus.} + </h2> + + <img alt="" + aria-describedby="txtImg0" + class="block-img-clickable__img" + src="${2:https://dummyimage.com/1024x768/ccc/000.png}" /> +</a> diff --git a/snippets/web-mode/buttons/button-link b/snippets/web-mode/buttons/button-link @@ -0,0 +1,22 @@ +# -*- mode: snippet -*- +# name: Link as a BUTTON (HTML/CSS) +# key: button-link +# -- + +<style> + .button-link { + background: ${1:#1192d1}; + border: 1px solid ${2:#1192d1}; + color: ${3:#ffffff}; + display: inline-block; + font-size: 1rem; + line-height: 1; + padding: 0.75em 1.25em; + text-align: center; + text-decoration: none; + } +</style> + +<a class="block-img-clickable" href="${4:#}"> + ${5:Lorem ipsum} +</a> diff --git a/snippets/web-mode/css-default b/snippets/web-mode/css-default @@ -0,0 +1,52 @@ +# -*- mode: snippet -*- +# name: CSS Defaults +# key: cssdef +# -- + +<style media="screen"> + :root { + font-size: calc(1vw + 1vh + .5vmin); + } + + html, + body { + height: 100%; + min-height: 100%; + } + + body { + background: #eee; + color: #111; + font: 1rem/1.6 monospace; + } + + body > * { + margin: auto; + max-width: 960px; + width: auto; + } + + img { + max-width: 100%; + width: auto; + } + + button, + input, + optgroup, + select, + textarea { + font-family: inherit; + } + + .visuallyhidden { + border: 0; + clip: rect(0 0 0 0); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + } +</style> diff --git a/snippets/web-mode/iframe-responsive b/snippets/web-mode/iframe-responsive @@ -0,0 +1,33 @@ +# -*- mode: snippet -*- +# name: Responsive iframe embeded video (HTML/CSS) +# key: iframe-responsive +# -- + +<style> + .iframe-rwd { + overflow: hidden; + padding: 56.25% 0 0 0; + position: relative; + } + + .iframe-rwd__iframe { + border: 0; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; + } +</style> + +<div class="iframe-rwd"> + <iframe + allow="fullscreen" + allowfullscreen + class="iframe-rwd__iframe" + frameborder="0" + height="360" + src="${1:https://player.vimeo.com/video/25805461}" + width="640"> + </iframe> +</div> diff --git a/snippets/web-mode/locize-use-translation b/snippets/web-mode/locize-use-translation @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# name: Locize t() +# key: locize_t +# -- + +{t('')}