initial commit

This commit is contained in:
Phuntsok Drak-pa 2019-09-29 17:58:22 +02:00
commit 0a37165d0e
4 changed files with 178 additions and 0 deletions

32
README.org Normal file
View File

@ -0,0 +1,32 @@
#+TITLE: Dired-Phundrak layer
#+author: Lucien “Phundrak” Cartier-Tilet
#+TAGS: layer|dired|configuration|phundrak
[[img/dired-phundrak.png]]
* Table of Contents :TOC_4_gh:noexport:
- [[#description][Description]]
- [[#features][Features:]]
- [[#install][Install]]
- [[#key-bindings][Key bindings]]
* Description
This layer adds my custom configuration of Dired on top of the default dired
configuration for Spacemacs.
** Features:
- Autocomplete
- Lint
- Refactor
- ...
* Install
To use this configuration layer, add it to your =~/.spacemacs=. You will need
to add =dired-phundrak= to the existing =dotspacemacs-configuration-layers=
list in this file.
* Key bindings
| Key Binding | Description |
|-------------+--------------|
| ~SPC x x x~ | Does thing01 |

96
funcs.el Normal file
View File

@ -0,0 +1,96 @@
;;; packages.el --- dired-phundrak layer functions file for Spacemacs.
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;;
;; Author: Lucien Cartier-Tilet <phundrak@phundrak.fr>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
; Custom functions ;;;;;;;;;;;;;;;;;;;;
(defun phundrak//open-marked-files (&optional @fname)
"Open all marked files in dired buffer as new Emacs buffers"
(interactive)
(let* (($file-list (if @fname
(progn (list @fname))
(if (string-equal major-mode "dired-mode")
(dired-get-marked-files)
(list (buffer-file-name))))))
(mapc (lambda ($fpath)
(find-file $fpath))
$file-list)))
(defun xah//open-in-external-app (&optional @fname)
"Open the current file or dired marked file in external app.
The app is chosen from your OS preference.
When called in emacs lisp, if @fname is given, open that.
URL `http://ergoemacs.org/emacs/emacs_dired_open_file_in_ext_apps.html'
Version 2019-01-18"
(interactive)
(let* (($file-list (if @fname
(progn (list @fname))
(if (string-equal major-mode "dired-mode")
(dired-get-marked-files)
(list (buffer-file-name)))))
($do-it-p (if (<= (length $file-list) 5)
t
(y-or-n-p "Open more than 5 files? "))))
(when $do-it-p
(mapc (lambda ($fpath)
(let ((process-connection-type nil))
(start-process "" nil "xdg-open" $fpath)))
$file-list))))
(defun xah//dired-sort ()
"Sort dired dir listing in different ways. Prompt for a choice.
URL `http://ergoemacs.org/emacs/dired_sort.html'
Version 2018-12-23, modified by Phundrak on 2019-08-06"
(interactive)
(let ($sort-by $arg)
(setq $sort-by (ido-completing-read "Sort by:" '( "name" "size" "date" "extension" )))
(cond
((equal $sort-by "name") (setq $arg "-ahl --group-directories-first"))
((equal $sort-by "date") (setq $arg "-ahl -t --group-directories-first"))
((equal $sort-by "size") (setq $arg "-ahl -S --group-directories-first"))
((equal $sort-by "extension") (setq $arg "-ahlD -X --group-directories-first"))
(t (error "logic error 09535" )))
(dired-sort-other $arg )))
(defun xah//dired-rename-space-to-underscore ()
"In dired, rename current or marked files by replacing space to
underscore _. If not in `dired', do nothing.
URL
`http://ergoemacs.org/emacs/elisp_dired_rename_space_to_underscore.html'
Version 2017-01-02"
(interactive)
(require 'dired-aux)
(if (equal major-mode 'dired-mode)
(progn
(mapc (lambda (x)
(when (string-match " " x )
(dired-rename-file x (replace-regexp-in-string " " "_" x) nil)))
(dired-get-marked-files ))
(revert-buffer))
(user-error "Not in dired.")))
(defun xah//dired-rename-space-to-hyphen ()
"In dired, rename current or marked files by replacing
space to hyphen -. If not in `dired', do nothing.
URL `http://ergoemacs.org/emacs/elisp_dired_rename_space_to_underscore.html'
Version 2016-12-22"
(interactive)
(require 'dired-aux)
(if (equal major-mode 'dired-mode)
(progn
(mapc (lambda (x)
(when (string-match " " x )
(dired-rename-file x (replace-regexp-in-string " " "_" x) nil)))
(dired-get-marked-files ))
(revert-buffer))
(user-error "Not in dired")))

12
keybindings.el Normal file
View File

@ -0,0 +1,12 @@
;;; keybindings.el --- dired-phundrak layer keybinding file for Spacemacs.
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;;
;; Author: Lucien Cartier-Tilet <phundrak@phundrak.fr>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(global-set-key (kbd "<s-f1>") (lambda () (interactive) (dired "~/")))

38
packages.el Normal file
View File

@ -0,0 +1,38 @@
;;; packages.el --- dired-phundrak layer packages file for Spacemacs.
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;;
;; Author: Lucien Cartier-Tilet <phundrak@phundrak.fr>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defconst dired-phundrak-packages '(dired-x image-dired+ org-download)
"The list of Lisp packages required by the dired-phundrak layer.")
(defun dired-phundrak/post-init-dired-x ()
"Initializes dired-x and adds keybindings for its exposed functionalities."
(use-package dired-x
:defer t
:init (progn
(define-key dired-mode-map "f" 'phundrak//open-marked-files)
(define-key dired-mode-map "F" 'xah//open-in-external-app)
(define-key dired-mode-map "s" 'xah//dired-sort)
(define-key dired-mode-map "-" 'xah//dired-rename-space-to-hyphen)
(define-key dired-mode-map "_" 'xah//dired-rename-space-to-underscore))))
(defun dired-phundrak/init-image-dired+ ()
"Initializes image-dired+ and adds keybindings for its exposed functionalities."
(use-package image-dired+
:defer t
:init ()))
(defun dired-phundrak/post-init-org-download ()
"Initializes org-download and adds keybindings for its exposed functionalities."
(use-package org-download
:defer t
:init ()))
;;; packages.el ends here