Skip to content

Instantly share code, notes, and snippets.

@AndrewNatoli
Created February 7, 2023 16:43
Show Gist options
  • Save AndrewNatoli/58c9b4dd967b39423b8ca05909f4cf53 to your computer and use it in GitHub Desktop.
Save AndrewNatoli/58c9b4dd967b39423b8ca05909f4cf53 to your computer and use it in GitHub Desktop.
Some Doom Emacs config snippets
(global-set-key (kbd "C-c d b a") 'dap-breakpoint-add)
(global-set-key (kbd "C-c d b d") 'dap-breakpoint-delete)
(global-set-key (kbd "C-c d b t") 'dap-breakpoint-toggle)
(global-set-key (kbd "C-c d b l") 'dap-ui-breakpoints-list)
(defun center-window-h ()
(let* ((display-width (x-display-pixel-width))
(frame-width (frame-pixel-width))
(left-offset (/ (- display-width frame-width) 2)))
(set-frame-position (selected-frame) left-offset 0)))
(defun set-frame-size-according-to-resolution ()
(interactive)
(if window-system
(progn
;; Set the width to half of the screen's horizontal resolution by character count
;; Not perfect but it's close enough
(setq char-width (frame-char-width))
(setq screen-width (x-display-pixel-width))
(setq char-count (floor (/ screen-width char-width)))
(add-to-list 'default-frame-alist (cons 'width (floor (/ char-count 2))))
;; height
(add-to-list 'default-frame-alist
(cons 'height (/ (- (x-display-pixel-height) 20)
(frame-char-height))))
(add-to-list 'default-frame-alist '(top . 0)))))
(set-frame-size-according-to-resolution)
(add-hook 'window-setup-hook 'center-window-h)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment