emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/crux 1e591c5 031/112: Merge pull request #16 from jiegec/m


From: ELPA Syncer
Subject: [nongnu] elpa/crux 1e591c5 031/112: Merge pull request #16 from jiegec/master
Date: Wed, 11 Aug 2021 09:57:48 -0400 (EDT)

branch: elpa/crux
commit 1e591c5a1ecfa99fcd67105a58b2e7d782abf969
Merge: 3042f6f 79e500e
Author: Bozhidar Batsov <bozhidar.batsov@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>

    Merge pull request #16 from jiegec/master
    
    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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]