Skip to content

Commit

Permalink
refactor(core): simplify and remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Dec 7, 2023
1 parent 86dc4ec commit 6c3a45e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 29 deletions.
23 changes: 3 additions & 20 deletions core/me-builtin.el
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,15 @@
tab-width 2) ; Small tab is enough!

;; Inhibit startup message in echo area the brutal way!
;; The `inhibit-startup-echo-area-message' variable is very restrictive, there
;; is only one unique way of setting it right!
;; The `inhibit-startup-echo-area-message' variable is very restrictive, there is only one unique way of setting it right!
;; See: reddit.com/r/emacs/comments/6e9o4o/comment/di8q1t5
(fset 'display-startup-echo-area-message #'ignore)

;;; Why use anything but UTF-8?
(prefer-coding-system 'utf-8)
(set-charset-priority 'unicode)
(set-default-coding-systems 'utf-8)
;; I use mainly English and French. Hence the "Latin-1" which is suitable for
;; major Western Europe languages.
;; I use mainly English and French. Hence the "Latin-1" which is suitable for major Western Europe languages.
(set-language-environment "Latin-1")
(set-locale-environment "en_US.UTF-8")
;; Use UTF-16-LE in Windows, see: rufflewind.com/2014-07-20/pasting-unicode-in-emacs-on-windows
Expand All @@ -200,8 +198,7 @@ or file path may exist now."
(eq buffer (window-buffer (selected-window))) ;; Only visible buffers
(set-auto-mode)))))

;; Advice `emacs-session-filename' to ensure creating "session.ID" files in a
;; sub-directory
;; Advice `emacs-session-filename' to ensure creating "session.ID" files in a sub-directory
(advice-add
#'emacs-session-filename :filter-return
(defun +emacs-session-filename--in-subdir-a (session-filename)
Expand Down Expand Up @@ -468,20 +465,6 @@ or file path may exist now."
(auto-insert-directory (+directory-ensure minemacs-local-dir "auto-insert/")))

(use-package hideif
:init
(defun +hide-ifdef-mode-maybe-h ()
;; If `me-lsp' is enabled, `lsp-semantic-tokens-mode' should do a better job,
;; so we don't enable `hide-ifdef-mode'.
(unless (or (bound-and-true-p lsp-semantic-tokens-mode)
(bound-and-true-p lsp-semantic-tokens-enable))
(hide-ifdef-mode 1)))
(defun +hide-ifdef-auto-enable ()
(interactive)
(if prefix-arg
(+remove-hook! (c-mode c-ts-mode c++-mode c++-ts-mode cuda-mode opencl-mode)
#'+hide-ifdef-mode-maybe-h)
(+add-hook! (c-mode c-ts-mode c++-mode c++-ts-mode cuda-mode opencl-mode)
:depth 101 #'+hide-ifdef-mode-maybe-h)))
:custom
(hide-ifdef-shadow t)
(hide-ifdef-initially t))
Expand Down
14 changes: 5 additions & 9 deletions core/me-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -1083,15 +1083,11 @@ by `+screenshot-delay') before taking the screenshot."

(defun +region-or-thing-at-point ()
"Return the region or the thing at point."
(when-let ((thing (condition-case nil
(or (prog1 (thing-at-point 'region t)
(deactivate-mark))
(cl-some (+apply-partially-right #'thing-at-point t)
'(symbol email number string word)))
;; Sometimes, specially when in an empty buffer,
;; `thing-at-point' can raise an error, in this case, lets just
;; start with an empty string
(error ""))))
(when-let ((thing (ignore-errors
(or (prog1 (thing-at-point 'region t)
(deactivate-mark))
(cl-some (+apply-partially-right #'thing-at-point t)
'(symbol email number string word))))))
;; If the matching thing has multi-lines, join them
(string-join (string-lines thing))))

Expand Down

0 comments on commit 6c3a45e

Please sign in to comment.