Skip to content

Commit

Permalink
qol: add backslash / slash toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
mcraveiro committed Mar 16, 2024
1 parent e0ecb10 commit ad57106
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/development.org
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ _p_rev _u_pper (mine) _=_: upper/lower _r_esolve

(add-hook 'imenu-list-major-mode-hook
(lambda ()
(imenu-list-minor-mode
(imenu-list-minor-mode)
(read-only-mode)
(hl-line-mode)))))
(hl-line-mode))))

(defun cunene/path-to-omnisharp ()
"Returns the path to the LSP server for C#."
Expand Down
16 changes: 16 additions & 0 deletions config/quality_of_life.org
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,22 @@ character of the string."
(insert new-c)
(replace-string new-c old-c nil (1+ start) end)))))

(defun cunene/backslash-slash-toggle ()
"Replace backslash/slash in the current region or line.
If the current line contains more backslash char than slashes, then replace
them to slashes, else replace slashes to backslashes. If there's a text
selection, work on the selected text."
(interactive)
(let (li bds)
(setq bds
(if (region-active-p)
(cons (region-beginning) (region-end))
(bounds-of-thing-at-point 'line)))
(setq li (buffer-substring-no-properties (car bds) (cdr bds)))
(if (> (count 47 li) (count 92 li))
(progn (replace-string "/" "\\" nil (car bds) (cdr bds)))
(progn (replace-string "\\" "/" nil (car bds) (cdr bds))))))

(defun cunene/space-to-underscore-region (start end)
"Replace space by underscore in region.
START and END mark the region."
Expand Down

0 comments on commit ad57106

Please sign in to comment.