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
master
Macoy Madson 4 years ago
parent
commit
72e65c8df0
  1. 53
      Emacs/desktop-management.el
  2. 1
      Emacs/drill-customizations.el
  3. 7
      Emacs/keybinds.el
  4. 70
      Emacs/org-customizations.el
  5. 15
      Emacs/syntaxes.el

53
Emacs/desktop-management.el

@ -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)
macoy-selected-desktop)
(progn
(setq desktop-list (remove (file-name-nondirectory macoy-selected-desktop) desktop-list))
(add-to-list 'desktop-list (file-name-nondirectory macoy-selected-desktop))
)
desktop-list
)))
(defun macoy-switch-desktop ()
"Use ido to list desktops to switch to"
"Use ido to list desktops to switch to"
(interactive)
(desktop-change-dir
(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: "
(macoy-get-desktop-list)))))
(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"
(interactive)
(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)

1
Emacs/drill-customizations.el

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

7
Emacs/keybinds.el

@ -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
)
;;

70
Emacs/org-customizations.el

@ -49,3 +49,73 @@
(setq org-agenda-files (list "C:/Users/mmadson/Dropbox/Org/1_Calendar.org"
"C:/Users/mmadson/Dropbox/Org/0_Dump.org"))
)
;; From https://orgmode.org/manual/Languages.html#Languages
;; Because I was too lazy to find the actual internal list
(setq macoy-org-code-block-languages (list
"asymptote"
"lua"
"awk"
"matlab"
"C"
"mscgen"
"C++"
"ocaml"
"clojure"
"octave"
"css"
"org"
"D"
"oz"
"ditaa"
"perl"
"calc"
"plantuml"
"processing"
"fortran"
"python"
"gnuplot"
"R"
"screen"
"ruby"
"dot"
"sass"
"haskell"
"scheme"
"java"
"sed"
"js"
"sh"
"latex"
"sql"
"ledger"
"sqlite"
"lilypond"
"vala"
"lisp"
))
(defun macoy-org-insert-code-block ()
(interactive)
(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"
(interactive)
(when (use-region-p)
(simpleclip-set-contents (format "[[file:%s::%d][%s:%d]]\n#+BEGIN_SRC %s\n%s\n#+END_SRC"
(buffer-file-name)
(line-number-at-pos (region-beginning))
(buffer-name)
(line-number-at-pos (region-beginning))
(ido-completing-read "Language: " macoy-org-code-block-languages)
(buffer-substring (region-beginning) (region-end)))
)
)
)
)

15
Emacs/syntaxes.el

@ -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 http://web-mode.org/ "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")

Loading…
Cancel
Save