Browse Source

Switch most recent desktop, org code block shortcuts

* Desktop now has most recent desktop at top of list if you haven't
  ever selected a desktop this session (e.g. right after startup)
* Added some convenience functions for creating org code blocks
* Added keybind for mc/skip-to-next-like-this
* Wrap web-mode with require block
Macoy Madson 4 years ago
  1. 53
  2. 1
  3. 7
  4. 70
  5. 15


@ -1,10 +1,17 @@
;; save/restore opened files
(desktop-save-mode 1)
;; This is needed only for theming. Desktop frames hold on to color values for some reason. We don't
;; care too much about losing our frame configurations so this is okay
(setq desktop-restore-frames nil)
;; Used to know whether or not to show the last selected desktop at the top of the desktop list
(setq macoy-has-ever-selected-desktop-this-session nil)
(defcustom macoy-selected-desktop nil
"The last selected desktop. This is used to load the most recent desktop when starting Emacs")
;; Faster desktop creation/switching
@ -19,15 +26,47 @@
(let ((new-desktop (concat macoy-desktop-dir new-desktop-name)))
(make-directory new-desktop)
(desktop-save new-desktop)
(customize-save-variable 'macoy-selected-desktop new-desktop)
(message "Created desktop at %s" new-desktop)
(setq macoy-has-ever-selected-desktop-this-session t)
(defun macoy-get-desktop-list ()
(let ((desktop-list (remove "."
(remove ".."
(directory-files macoy-desktop-dir)))))
;; If we've never picked a desktop this session, put the last used desktop at the top of the
;; list. This is a workaround while I don't know how to make my desktop switch happen after
;; the regular emacs behavior picks the desktop during startup.
(if (and (not macoy-has-ever-selected-desktop-this-session)
(setq desktop-list (remove (file-name-nondirectory macoy-selected-desktop) desktop-list))
(add-to-list 'desktop-list (file-name-nondirectory macoy-selected-desktop))
(defun macoy-switch-desktop ()
"Use ido to list desktops to switch to"
"Use ido to list desktops to switch to"
(concat macoy-desktop-dir
(ido-completing-read "Switch Desktop: "
(remove "."
(remove ".."
(directory-files macoy-desktop-dir)))))))
(let ((selected-desktop
(concat macoy-desktop-dir
(ido-completing-read "Switch Desktop: "
(message "%s" selected-desktop)
(customize-save-variable 'macoy-selected-desktop selected-desktop)
(desktop-change-dir selected-desktop)
(setq macoy-has-ever-selected-desktop-this-session t)
(defun macoy-reload-last-desktop ()
"Load the last desktop which was saved or switched to via the macoy-desktop system"
(desktop-change-dir macoy-selected-desktop)
(message "Restored desktop %s" macoy-selected-desktop)
(setq macoy-has-ever-selected-desktop-this-session t)
(global-set-key (kbd "M-b") 'macoy-reload-last-desktop)


@ -35,6 +35,7 @@
(switch-to-buffer "*Macoy-Drill-Convert*")
(with-current-buffer "*Macoy-Drill-Convert*"
;; Override the level because we don't care about levels in drill,
;; but want to see them in non-drill notes


@ -204,14 +204,17 @@
(global-set-key (kbd "C-d") 'mc/mark-next-like-this)
;;(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
(global-set-key (kbd "M-<f3>") 'mc/mark-all-like-this)
;; Adds one cursor to each line in the current region.
(global-set-key (kbd "C-S-l") 'mc/edit-lines)
(define-key mc/keymap (kbd "C-S-d") 'mc/skip-to-next-like-this)
;; Make <return> insert a newline; multiple-cursors-mode can still be disabled with C-g.
(define-key mc/keymap (kbd "<return>") nil)
;; Clear these so that expand-region can have them
(define-key mc/keymap (kbd "C-'") nil)
(define-key mc/keymap (kbd "C-\"") nil)
(define-key mc/keymap (kbd "C-SPC") 'mc-hide-unmatched-lines-mode)
;; Adds one cursor to each line in the current region.
(global-set-key (kbd "C-S-l") 'mc/edit-lines)
;; Note that in my-keys I define cut, copy, and paste overrides which work with simpleclip & mc


@ -49,3 +49,73 @@
(setq org-agenda-files (list "C:/Users/mmadson/Dropbox/Org/"
;; From
;; Because I was too lazy to find the actual internal list
(setq macoy-org-code-block-languages (list
(defun macoy-org-insert-code-block ()
(insert (format "#+BEGIN_SRC %s\n\n#+END_SRC"
(ido-completing-read "Language: " macoy-org-code-block-languages)))
(forward-line -1)
(when (require 'simpleclip)
(defun macoy-org-copy-code-block ()
"Intended to be executed from a source file while region is active. Create a link and org code
block and set the clipboard to it"
(when (use-region-p)
(simpleclip-set-contents (format "[[file:%s::%d][%s:%d]]\n#+BEGIN_SRC %s\n%s\n#+END_SRC"
(line-number-at-pos (region-beginning))
(line-number-at-pos (region-beginning))
(ido-completing-read "Language: " macoy-org-code-block-languages)
(buffer-substring (region-beginning) (region-end)))


@ -4,10 +4,10 @@
;; This is for better syntax highlighting when editing templated web files (e.g. files with Nunjucks)
;; Only enabled at work because I don't use templates at home
(when (string-equal (user-login-name) "mmadson")
;; Only enabled at work because I only need web mode for template stuff
(when (and (string-equal (user-login-name) "mmadson") (require 'web-mode))
;; TODO: Customize colors (see "Syntax highlighting")
(require 'web-mode)
;; I like to manually enable rainbow-mode if I want to see colors (this might not work...)
(setq web-mode-enable-css-colorization nil)
@ -25,6 +25,15 @@
;; Doesn't work because these args aren't the right command
;; (when (require 'web-beautify)
;; ;; Override this function so I can customize args. Why did they make it defconst...
;; (defconst macoy-web-beautify-args '("-f" "-t" "-"))
;; (defun web-beautify-get-shell-command (program)
;; "Join PROGRAM with the constant js-beautify args."
;; (mapconcat 'identity (append (list program) macoy-web-beautify-args) " "))
;; )
;; Jam
(load-user-file "jam-mode.el")