diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2021-10-17 17:47:27 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2021-10-17 17:47:27 +0200 |
| commit | 9353a2934fe32ce092b66739eee454fed443743a (patch) | |
| tree | 43cb1fe4d59f69924daa326a707b61a60b0ad90c /.emacs.d/lisp | |
| parent | 7ac28a401765b0be829ed6746e57c13ecc709c98 (diff) | |
| download | dotfiles-9353a2934fe32ce092b66739eee454fed443743a.tar.gz dotfiles-9353a2934fe32ce092b66739eee454fed443743a.zip | |
emacs: switched to Doom Emacs
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to '.emacs.d/lisp')
| -rw-r--r-- | .emacs.d/lisp/README.org | 18 | ||||
| -rw-r--r-- | .emacs.d/lisp/g.el | 138 |
2 files changed, 0 insertions, 156 deletions
diff --git a/.emacs.d/lisp/README.org b/.emacs.d/lisp/README.org deleted file mode 100644 index 8a19d13..0000000 --- a/.emacs.d/lisp/README.org +++ /dev/null @@ -1,18 +0,0 @@ -* GNU Emacs Modules written by Miquel Sabaté Solà - -This directory contains Lisp modules I've written. - -** g.el - -A port of my [[https://github.com/mssola/g][g]] script for GNU Emacs. This is not helpful all the time, but it -does help whenever Projectile does not cover me. This module implements the -following interactive functions: - -- =g=: allows users to jump through a shortcut. After performing the jump, the - user will be presented with the [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Dired.html][dired]] mode. -- =g-add=: add a new shortcut that points to a valid path. -- =g-remove=: remove an existing shortcut. -- =g-list=: list all the available shortcuts. - -This module is completely compatible with the =g.sh= script, which means that -they both can be run side by side without any problems. diff --git a/.emacs.d/lisp/g.el b/.emacs.d/lisp/g.el deleted file mode 100644 index 5c1dba1..0000000 --- a/.emacs.d/lisp/g.el +++ /dev/null @@ -1,138 +0,0 @@ -;;; g.el --- Adding shortcuts -*- lexical-binding: t; -*- -;; -;; Copyright (C) 2016-2021 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 -;; (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 is a GNU Emacs port of my g.sh bash script that can be found here: -;; https://github.com/mssola/g. This package can be seen as useless given the -;; fantastic Helm + Projectile combo, but it still comes in handy when you want -;; to edit: -;; - A file which is in a project unknown to Projectile. -;; - A file that does not really belong to a real project. - -;;; Code: - -(defvar g-file "~/.gfile" - "The path to the gfile.") - -;;; 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)) - "")) - -(defun g-write (shortcuts) - "Write the given SHORTCUTS into the gfile." - - (let ((output "")) - (maphash (lambda (key value) - (setq output - (concat output (format "%s\n%s\n" key value)))) - shortcuts) - (write-region output nil g-file))) - -(defun g-read () - "Read all the shortcuts as defined by the gfile. -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. - (dotimes (i (/ (length list) 2)) - (let ((n (* i 2))) - (puthash - (nth n list) - (nth (+ n 1) list) - shortcuts))) - shortcuts)) - -;;; Interactive functions - -(defun g () - "Go to the given directory with the supplied alias." - - (interactive) - - (if (file-exists-p g-file) - (progn - (let* ((shortcuts (g-read)) - (alias (completing-read - "Give me the name: " shortcuts nil t))) - (find-file (gethash alias shortcuts)))) - (message "Add a shortcut first!"))) - -(defun g-list () - "List all the available shortcuts." - - (interactive) - - (let ((output "")) - (maphash (lambda (key value) - (setq output - (concat output (format "%s => %s\n" key value)))) - (g-read)) - (message output))) - -(defun g-add () - "Add a new shortcut." - - (interactive) - - (let ((shortcuts (g-read)) - (to-create (read-string "Shortcut to create: "))) - (if (gethash to-create shortcuts) - (message "Error: shortcut already exists.") - (let ((path (read-file-name "Path: " nil nil t))) - (if (file-exists-p path) - (progn - (puthash to-create (file-truename path) shortcuts) - (g-write shortcuts)) - (message "Error: given path does not exist.")))))) - -(defun g-remove () - "Remove an existing shortcut." - - (interactive) - - (if (file-exists-p g-file) - (progn - (let* ((shortcuts (g-read)) - (alias (completing-read - "Give me the shortcut to remove: " shortcuts nil t))) - (remhash alias shortcuts) - (g-write shortcuts))) - (message "There are no shortcuts!"))) - -(provide 'g) - -;;; g.el ends here |
