Commits

Juan Fuentes committed 757e647

Fixed typos
Added start-or-switch() function, based on prelude-start-or-switch-to().

Comments (0)

Files changed (1)

site-lisp/defuns.el

 prompt you for a shell command to run and replaces region with
 the results.  This is handy for doing things like getting
 external program locations in scripts and running grep and
-whatnot on a region."
+not on a region."
   (interactive)
   (save-excursion
     (if (equal mark-active nil)
       (eshell)
       (delete-other-windows))))
 
+(defun jj/start-or-switch(func buffer-name)
+  "Call func if there is no buffer with buffer-name, or switch to buffer-name.
+   Don't clobber current buffer."
+  (if (not (get-buffer buffer-name))
+      (progn
+        (split-window-sensibly (selected-window))
+        (other-window 1)
+        (funcall func))
+      (switch-to-buffer-other-window buffer-name)))
+
+
 ;; indenting utility functions taken from http://bit.ly/WWwD11
 (defun indent-buffer()
   "Indent the currently visited buffer."
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.