[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/crux 79e500e 030/112: Add multiple choice with completion
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/crux 79e500e 030/112: Add multiple choice with completion for shell init files. |
Date: |
Wed, 11 Aug 2021 09:57:47 -0400 (EDT) |
branch: elpa/crux
commit 79e500e9168875f1391888126c51dba04742c1b6
Author: Jiege Chen <jiegec@qq.com>
Commit: Jiege Chen <jiegec@qq.com>
Add multiple choice with completion for shell init files.
---
crux.el | 46 +++++++++++++++++++++++++++++++++++++---------
1 file changed, 37 insertions(+), 9 deletions(-)
diff --git a/crux.el b/crux.el
index 9ff1a7b..244344a 100644
--- a/crux.el
+++ b/crux.el
@@ -53,6 +53,31 @@
:type 'string
:group 'crux)
+(defcustom crux-shell-zsh-init-files '("$HOME/.zshrc" "$HOME/.zlogin"
"$HOME/.zprofile" "$HOME/.zshenv" "$HOME/.zlogout" "/etc/zshenv"
"/etc/zprofile" "/etc/zshrc" "/etc/zlogin" "/etc/zlogout" "$ZDOTDIR/.zshrc"
"$ZDOTDIR/.zlogin" "$ZDOTDIR/.zprofile" "$ZDOTIR/.zshenv" "$ZDOTDIR/.zlogout")
+ "The default init files of zsh."
+ :type 'list
+ :group 'crux)
+
+(defcustom crux-shell-bash-init-files '("$BASH_ENV" "$HOME/.bashrc"
"$HOME/.bash_profile" "$HOME/.bash_login" "$HOME/.profile" "$HOME/.bash_logout"
"/etc/bashrc" "/etc/bash_profile" "/etc/bash_login" "/etc/profile"
"/etc/bash_logout")
+ "The default init files of bash."
+ :type 'list
+ :group 'crux)
+
+(defcustom crux-shell-tcsh-init-files '("$HOME/.login" "$HOME/.cshrc"
"$HOME/.tcshrc" "$HOME/.logout" "/etc/csh.cshrc" "/etc/csh.login"
"/etc/csh.logout")
+ "The default init files of tcsh."
+ :type 'list
+ :group 'crux)
+
+(defcustom crux-shell-fish-init-files '("$HOME/.config/fish/config.fish"
"$XDG_CONFIG_HOME/fish/config.fish")
+ "The default init files of fish."
+ :type 'list
+ :group 'crux)
+
+(defcustom crux-shell-ksh-init-files '("$HOME/.profile" "$ENV" "/etc/profile")
+ "The default init files of ksh."
+ :type 'list
+ :group 'crux)
+
(defun crux-open-with (arg)
"Open visited file in default external program.
When in dired mode, open file under the cursor.
@@ -95,8 +120,8 @@ the current buffer."
"Create or visit a terminal buffer."
(interactive)
(crux-start-or-switch-to (lambda ()
- (ansi-term crux-shell (concat
crux-term-buffer-name "-term")))
- (format "*%s-term*" crux-term-buffer-name)))
+ (ansi-term crux-shell (concat
crux-term-buffer-name "-term")))
+ (format "*%s-term*" crux-term-buffer-name)))
(defun crux-indent-rigidly-and-copy-to-clipboard (begin end arg)
"Indent region between BEGIN and END by ARG columns and copy to clipboard."
@@ -352,13 +377,16 @@ Doesn't mess with special buffers."
(interactive)
(let* ((shell (car (reverse (split-string (getenv "SHELL") "/" t))))
(shell-init-file (cond
- ((string= "zsh" shell) ".zshrc")
- ((string= "bash" shell) ".bashrc")
- ((string= "tcsh" shell) ".login")
- ((string= "fish" shell) ".config/fish/config.fish")
- ((string-prefix-p "ksh" shell) ".profile")
- (t (error "Unknown shell")))))
- (find-file-other-window (expand-file-name shell-init-file (getenv
"HOME")))))
+ ((string= "zsh" shell) crux-shell-zsh-init-files)
+ ((string= "bash" shell) crux-shell-bash-init-files)
+ ((string= "tcsh" shell) crux-shell-tcsh-init-files)
+ ((string= "fish" shell) crux-shell-fish-init-files)
+ ((string-prefix-p "ksh" shell)
crux-shell-ksh-init-files)
+ (t (error "Unknown shell"))))
+ (candidates (cl-remove-if-not 'file-exists-p (mapcar
'substitute-in-file-name shell-init-file))))
+ (if (> (length candidates) 1)
+ (find-file-other-window (completing-read "Choose shell init file:"
candidates))
+ (find-file-other-window (car candidates)))))
;;
http://endlessparentheses.com/ispell-and-abbrev-the-perfect-auto-correct.html
(defun crux-ispell-word-then-abbrev (p)
- [nongnu] elpa/crux 16eb56d 011/112: Kill crux-setup-default-keybindings, (continued)
- [nongnu] elpa/crux 16eb56d 011/112: Kill crux-setup-default-keybindings, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux d2643ae 019/112: Add crux-ispell-word-then-abbrev, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 382834e 020/112: Fix contributors link, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux e6e3221 025/112: Fix crux-*-file-and-buffer commands inconsistencies and alias the inverse, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 4c90762 026/112: Add complementary `with-region-or-line` & `with-region-or-point-to-eol`, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux e4c539b 028/112: Merge pull request #9 from waymondo/with-region-or-line, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux dc1606b 034/112: Add crux-transpose-windows for swapping the buffers between two windows, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 2be95ea 040/112: Use read-from-minibuffer for the new file name, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux e2124c8 023/112: Merge pull request #6 from verdammelt/patch-1, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 3c14b4a 024/112: Merge pull request #13 from jiegec/master, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 79e500e 030/112: Add multiple choice with completion for shell init files.,
ELPA Syncer <=
- [nongnu] elpa/crux e6c7421 035/112: Remove crux-swap-windows and alias it to crux-transpose-windows, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 5938c84 036/112: Merge pull request #21 from dgtized/transpose-windows, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 6d11d2e 039/112: When opening a line above, don't reindent the current line, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 1967a75 041/112: Allow users to create directories with crux-rename-file-and-buffer, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 582a68d 046/112: Fix the version header, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux bcbfdec 048/112: Don't assume ido when offering files from recentf (#33), ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 3b377b4 054/112: Add smart kill line function, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 1c2c179 061/112: Improve a docstring, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 2b6ddf0 060/112: Add missing space, ELPA Syncer, 2021/08/11
- [nongnu] elpa/crux 5a7201a 062/112: Fix a docstring, ELPA Syncer, 2021/08/11