- 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
Okay, I will improve your Emacs configuration. Here's what I'll do: #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,36 +1,43 @@ | ||
| ;; Bash settings | ||
| ;;; pkg-bash.el --- Bash completion -*- lexical-binding: t -*- | ||
| 
     | 
||
| (require-package 'bash-completion) | ||
| ;;; Commentary: | ||
| ;; This package configures bash completion. | ||
| 
     | 
||
| ;;; Code: | ||
| 
     | 
||
| ;; Function to turn off indent-tabs-mode | ||
| (defun turn-off-indent-tabs-mode () | ||
| "Turn off the use of tabs for indentation." | ||
| (setq indent-tabs-mode nil) | ||
| (setq tab-width 8)) | ||
| (require-package 'bash-completion) | ||
| (use-package bash-completion | ||
| :defer t | ||
| :config | ||
| ;; Function to turn off indent-tabs-mode. | ||
| (defun turn-off-indent-tabs-mode () | ||
| "Turn off the use of tabs for indentation." | ||
| (setq indent-tabs-mode nil) | ||
| (setq tab-width 8)) | ||
| 
     | 
||
| ;; Add hook for shell script mode | ||
| (add-hook 'sh-mode-hook 'turn-off-indent-tabs-mode) | ||
| ;; Add hook for shell script mode. | ||
| (add-hook 'sh-mode-hook 'turn-off-indent-tabs-mode) | ||
| 
     | 
||
| ;; Function to generate auto-complete candidates for bash | ||
| (defun ac-bash-candidates () | ||
| "Generate a list of potential completions for the current bash command. | ||
| ;; Function to generate auto-complete candidates for bash. | ||
| (defun ac-bash-candidates () | ||
| "Generate a list of potential completions for the current bash command. | ||
| This function is a modified version of `bash-completion-dynamic-complete' | ||
| from bash-completion.el." | ||
| (when bash-completion-enabled | ||
| (let* ((start (comint-line-beginning-position)) | ||
| (pos (point)) | ||
| (tokens (bash-completion-tokenize start pos)) | ||
| (open-quote (bash-completion-tokenize-open-quote tokens)) | ||
| (parsed (bash-completion-process-tokens tokens pos)) | ||
| (line (cdr (assq 'line parsed))) | ||
| (point (cdr (assq 'point parsed))) | ||
| (cword (cdr (assq 'cword parsed))) | ||
| (words (cdr (assq 'words parsed))) | ||
| (stub (nth cword words)) | ||
| (completions (bash-completion-comm line point words cword open-quote)) | ||
| ;; Override configuration for comint-dynamic-simple-complete. | ||
| ;; Bash adds a space suffix automatically. | ||
| (comint-completion-addsuffix nil)) | ||
| completions))) | ||
| (when bash-completion-enabled | ||
| (let* ((start (comint-line-beginning-position)) | ||
| (pos (point)) | ||
| (tokens (bash-completion-tokenize start pos)) | ||
| (open-quote (bash-completion-tokenize-open-quote tokens)) | ||
| (parsed (bash-completion-process-tokens tokens pos)) | ||
| (line (cdr (assq 'line parsed))) | ||
| (point (cdr (assq 'point parsed))) | ||
| (cword (cdr (assq 'cword parsed))) | ||
| (words (cdr (assq 'words parsed))) | ||
| (stub (nth cword words)) | ||
| (completions (bash-completion-comm line point words cword open-quote)) | ||
| ;; Override configuration for comint-dynamic-simple-complete. | ||
| ;; Bash adds a space suffix automatically. | ||
| (comint-completion-addsuffix nil)) | ||
| completions)))) | ||
| 
         
      Comment on lines
    
      +9
     to 
      +41
    
   
  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The   | 
||
| 
     | 
||
| (provide 'pkg-bash) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment to explain what the
condition-caseblock is doing, specifically what errors it is catching and why. This will improve the readability of the code.