Skip to content

Commit

Permalink
Various improvements (#239)
Browse files Browse the repository at this point in the history
* completion: improve

* editing: improve structured editing

* lisp/readable-typo-theme: keep normal size for echo area

* editing: fully replace smartparens with puni

* completion: avoid dabbrev-completion due to weird scrolling issues
  • Loading branch information
terlar authored Oct 19, 2023
1 parent d4345c4 commit 0daeb3c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 56 deletions.
61 changes: 30 additions & 31 deletions init.org
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ Completion Overlay Region FUnction.
[tab] 'corfu-next
"S-TAB" 'corfu-previous
[backtab] 'corfu-previous
"C-e" 'corfu-insert)
"C-e" 'corfu-complete)
:init
(setq corfu-auto t)
(setq corfu-cycle t)
Expand Down Expand Up @@ -1144,11 +1144,8 @@ Vertical interactive completion UI.
*** dabbrev
#+begin_src emacs-lisp :tangle yes
(use-package dabbrev
:general
;; Swap M-/ and C-M-/
("M-/" 'dabbrev-completion
"C-M-/" 'dabbrev-expand)
:init
(setq dabbrev-case-replace nil)
(setq dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
#+end_src

Expand Down Expand Up @@ -1433,28 +1430,37 @@ Cycle through words, symbols and patterns.
#+end_src

*** puni
Soft deletion and balanced expressions.
Structured editing with soft deletion and balanced expressions.
#+begin_src emacs-lisp :tangle yes
(use-package puni
:ensure t
:commands
(puni-kill-line
puni-kill-active-region)
puni-kill-active-region
puni-mark-list-around-point)
:preface
(defun puni-kill-whole-line-or-region (arg)
"Kill whole line(s) based on ARG or active region."
(defun puni-whole-line-or-region-kill (arg)
"Kill whole structured line(s) based on ARG or active region."
(interactive "P")
(if (use-region-p)
(puni-kill-active-region)
(if (or (> (or arg 1) 1)
(looking-at-p "^[[:blank:]]*$"))
(let ((kill-whole-line t))
(if (and (looking-at-p "^$") (= (or arg 1) 1))
(kill-line)
(save-excursion
(set-mark (line-beginning-position 1))
(goto-char (line-beginning-position (+ 1 (or arg 1))))
(puni-kill-active-region))
(save-excursion
(beginning-of-line)
(puni-kill-line 1)))))
(beginning-of-line)
(puni-kill-line arg))))))

(defun puni-whole-line-or-region-kill-ring-save (arg)
"Save whole structured line(s) based on ARG or active region."
(interactive "P")
(cl-letf (((symbol-function 'kill-region) #'kill-ring-save))
(puni-whole-line-or-region-kill arg)))

(defun puni-kill-list-around-point ()
(interactive)
(puni-mark-list-around-point)
(kill-region nil nil t))
:hook
(after-init-hook . puni-global-mode)
:general
Expand All @@ -1463,7 +1469,13 @@ Soft deletion and balanced expressions.
toggle-prefix '(puni-mode :wk "Structured editing"))
(:keymaps
'puni-mode-map
"C-w" 'puni-kill-whole-line-or-region))
[remap transpose-sexps] 'puni-transpose
"M-'" 'puni-kill-list-around-point
"M-D" 'puni-splice
"M-R" 'puni-squeeze
"M-W" 'puni-wrap-round
"C-w" 'puni-whole-line-or-region-kill
"M-w" 'puni-whole-line-or-region-kill-ring-save))
#+end_src

*** string-inflection
Expand All @@ -1476,19 +1488,6 @@ Toggle between snake/pascal/camel/up/kebab-case or capital underscore.
("M-_" 'string-inflection-all-cycle))
#+end_src

*** smartparens
Auto-insert matching parenthesis and highlight matching parenthesis.
#+begin_src emacs-lisp :tangle yes
(use-package smartparens
:ensure t
:general
("M-'" 'sp-change-inner
"M-C" 'sp-clone-sexp
"M-D" 'sp-unwrap-sexp
"M-R" 'sp-rewrap-sexp
"M-W" 'sp-wrap-round))
#+end_src

*** visual-regexp
Visually highlight regular expression searches as you type. Also supports replace.
#+begin_src emacs-lisp :tangle yes
Expand Down
4 changes: 2 additions & 2 deletions lisp/readable-typo-theme.el
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
;;;; Faces
(defface readable-typo-theme-echo-area
nil
"Face used for information of strong importance."
"Face used for echo area."
:group 'readable-mono-theme)

(let ((default-height readable-typo-theme-default-font-height)
Expand Down Expand Up @@ -160,7 +160,7 @@
`(variable-pitch ((t (:family ,variable-pitch :weight ,default-weight))))
`(variable-pitch-text ((t (:height 1.1 :family ,serif))))
`(bold ((t (:weight ,bold-weight))))
`(readable-typo-theme-echo-area ((t (:height ,small-height :family ,variable-pitch :weight ,default-weight))))
`(readable-typo-theme-echo-area ((t (:family ,variable-pitch :weight ,default-weight))))

;;;;; Interface
`(mode-line-active ((t (:family ,variable-pitch :height ,small-height))))
Expand Down
17 changes: 0 additions & 17 deletions lock/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions lock/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1225,12 +1225,6 @@
repo = "sly-quicklisp";
type = "github";
};
smartparens = {
flake = false;
owner = "Fuco1";
repo = "smartparens";
type = "github";
};
source-peek = {
flake = false;
owner = "iqbalansari";
Expand Down

0 comments on commit 0daeb3c

Please sign in to comment.