Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
seagle0128 committed Aug 8, 2024
1 parent e1f3a54 commit f7badfe
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
4 changes: 2 additions & 2 deletions lisp/init-completion.el
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ value of the selected COLOR."
;; :preview-key on a per-command basis using the `consult-customize' macro.
(consult-customize
consult-line consult-line-multi
:initial (thing-at-point 'symbol t)
:initial (selected-region-or-symbol-at-point)
:preview-key 'any
consult-buffer consult-recent-file consult-theme :preview-key '(:debounce 1.0 any)
consult-goto-line :preview-key '(:debounce 0.5 any)
consult-ripgrep consult-git-grep consult-grep
:initial (thing-at-point 'symbol t)
:initial (selected-region-or-symbol-at-point)
:preview-key '(:debounce 0.5 any))

;; Optionally configure the narrowing key.
Expand Down
42 changes: 24 additions & 18 deletions lisp/init-funcs.el
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@ Same as '`replace-string' `C-q' `C-m' `RET' `RET''."
(message "Copied '%s'" filename))
(warn "Current buffer is not attached to a file!"))))

(defun create-scratch-buffer ()
"Create a scratch buffer."
(interactive)
(switch-to-buffer (get-buffer-create "*scratch*"))
(lisp-interaction-mode))

(defun save-buffer-as-utf8 (coding-system)
"Revert a buffer with `CODING-SYSTEM' and save as UTF-8."
(interactive "zCoding system for visited file (default nil):")
(revert-buffer-with-coding-system coding-system)
(set-buffer-file-coding-system 'utf-8)
(save-buffer))

(defun save-buffer-gbk-as-utf8 ()
"Revert a buffer with GBK and save as UTF-8."
(interactive)
(save-buffer-as-utf8 'gbk))

(defun selected-region-or-symbol-at-point ()
"Return the selected region, otherwise return the symbol at point."
(if (region-active-p)
(buffer-substring-no-properties (region-beginning) (region-end))
(thing-at-point 'symbol t)))

;; Browse URL
(defun centaur-browse-url (url)
"Open URL using a configurable method.
Expand Down Expand Up @@ -195,24 +219,6 @@ See `browse-url' for more details."
(find-file-other-window centaur-custom-post-file)))

;; Misc
(defun create-scratch-buffer ()
"Create a scratch buffer."
(interactive)
(switch-to-buffer (get-buffer-create "*scratch*"))
(lisp-interaction-mode))

(defun save-buffer-as-utf8 (coding-system)
"Revert a buffer with `CODING-SYSTEM' and save as UTF-8."
(interactive "zCoding system for visited file (default nil):")
(revert-buffer-with-coding-system coding-system)
(set-buffer-file-coding-system 'utf-8)
(save-buffer))

(defun save-buffer-gbk-as-utf8 ()
"Revert a buffer with GBK and save as UTF-8."
(interactive)
(save-buffer-as-utf8 'gbk))

(defun byte-compile-elpa ()
"Compile packages in elpa directory. Useful if you switch Emacs versions."
(interactive)
Expand Down

0 comments on commit f7badfe

Please sign in to comment.