This post covers , Directories, Clipboard, and Command Line History from the "Default Operations" section of my init.

  • Selection Region and Mark

  • Browsers


Emacs is old school. You're either new to it - which means you wouldn't be here unless it was your type of thing - or you know what you're looking for. In either case, go to the side bar of this page and click on the 'Emacs' tag. Then read the posts y date from oldest to newest.

In the last emacs post I covered lines 1652 - 2003. This post covers lines 2004 - 2191. I include the lines for anyone that wants to patch together the entire init from start to finish. The lines won't always match up because I take stuff out when I'm in the init.


Transient mark mode should be included, so you can go ahead and skip those first few lines. Enabling auto-fill mode keeps your paragraphs at the fill-column width, set earlier with (setq fill-column 140). Play around with that width until your get your document exports as you want them. The unfill, which deselects fill-column width for that region, is often also a useful function. The expand region and change inner packages are great. I recommend to bind them to a short-cut and include them in the hydra. You can then edit the hydra to show the shortcut (I've yet to do that here.).

;(transient-mark-mode 1)
(make-variable-buffer-local 'transient-mark-mode)
(put 'transient-mark-mode 'permanent-local t)
(setq-default transient-mark-mode t)

;enables C-u C-<SPC>, to return to last mark, followed by C-<SPC> to cycle through all marks set
(setq set-mark-command-repeat-pop t)

(bind-key "C-c q" 'auto-fill-mode)

;unfill paragraph
(defun unfill-paragraph (&optional region)
"Takes a multi-line paragraph and makes it into a single line of text."
(interactive (progn (barf-if-buffer-read-only) '(t)))
(let ((fill-column (point-max))
	  ;; This would override `fill-column' if it's an integer.
	  (emacs-lisp-docstring-fill-column t))
  (fill-paragraph nil region)))

;useful packages
(use-package expand-region
:after hydra
(require 'expand-region)
(use-package change-inner
(require 'change-inner));end change inner
(defun ejmr-mark-line ()
    "Mark the current line."
    (set-mark (point))
);end use-package expand-region

(defvar region-title (with-faicon "book" "Marking The Region"))
;generate hydra
(pretty-hydra-define Region___ ( :title region-title :quit-key "q" :color Pink )
(   "A"
    ("r" er/expand-region "Expand Region" )
    ("j" er/contract-region "Contract Region" )
    ("i" change-inner "Mark Inside Brackets/Quotes" :color blue)
    ("l" ejmr-mark-line "Mark The Line" :color blue )
    ("t" er/mark-inside-pairs "Mark Inside Pairs" :color blue )
    ("u" er/mark-url "Mark Url" :color blue)
    ("w" er/mark-word "Mark Word" :color blue)
;    ("e" academic-phrases "Insert Academic Phrase (content ideas)" )
;    ("i" academic-phrases-by-section "Insert Academic Phrase (section ideas)" )
;    ("g" writegood-mode "Write Good Mode" :toggle t )

);end theme
    ("p" er/mark-paragraph "Mark Paragraph" )
    (";" er/mark-comment "Mark Comment")
    ("R" rectangle-mark-mode "Mark Rectangle")
    ("k" copy-rectangle-as-kill "Copy Rectangle" )
    ("Y" yank-rectangle "Paste Rectangle" )
    ("d" delete-rectangle "Delete Rectangle" )
    ("c"  sp-change-inner "Change Enclosed" :color blue )

);end highlighting

    ("s" er/mark-sentence "Mark Sentence" :color blue)
    ("y" helm-show-kill-ring "Helm Kill Ring")
;    ("n" clear-kill-ring "Clear Clip Board")
;    ("t" toggle-company-idle-delay "Toggle Company Dropdown")
;    ("l" query-replace-regexp "Find and Replace Text" :color blue)
;    ("o" Org-Central/body "Visit Org Central" :color blue)
;    ("E" Org-Editor/body "Org Editing Manager" :color blue)
;    ("#" count-words "Count Words")
    ("h" hydra-helm/body "Return To Helm" :color blue )
    ("<SPC>" nil "Quit" :color blue)
;    ("m" visual-fill-column-mode "Wrap Line Column"  :toggle t)
;    ("i" highlight-indent-guides-mode  "Show Indent Guides" :toggle t )
;    ("g" fci-mode "Show Fill Column" :toggle t )
);end miscellaneous
);end hydra body
);end pretty-hydra-appearance
(bind-key "<C-m> r" 'Region___/body)

emacs posiedon configuration region hydra code


The main challenge with this browser hydra is configuring the browse-url-default-browser to call the browser you want as a default. You only need to read browse.el which is included in your emacs installation. Then mess around with the various variables until you get it working. Or just use the code below and see if that works for you. Engine mode is a nifty package you can get through Melpa that enables you to search various engines directly from buffers in emacs. So type and highlight a phrase in a scratch buffer and use your browser hydra to interact with your browsers. See the hydra below. Also included are a couple of useful functions 'print-region-to-buffer' which turns the region into html in a buffer, and 'print-region-to-browser' which prints the region directly to the browser, where you can then print with your printer or turn it into a pdf. There are better styling options however exporting an org-mode file to html, because as you will see when we get there, you can more easily set up some default css.

;browse.el,set  browse-url-browser-function to browse-url-default-browser, browse-url-generic,-browse-url-chrome-program, whatever works
(setq browse-url-browser-function 'browse-url-default-browser)
(setq browse-url-firefox-program firefox-p)
(setq auto-window-vscroll nil)

;browse-url in this shortcut or hyrda
(bind-key "C-c C-o" 'browse-url)

;use package engine-mode
(use-package engine-mode
:after hydra
:commands Browse-Web/body
;(engine-mode t)
;engine mode configuration

(defengine duckduckgo
;:keybinding "d"

(defengine github
;:keybinding "h"

(defengine google
;:keybinding "g"

(defengine google-images
;:keybinding "i"

(defengine google-maps
:docstring "Mappin' it up."
;:keybinding "m"

(defengine stack-overflow
;:keybinding "q"

(defengine wikipedia
;:keybinding "w"
:docstring "Searchin' the wikis.")

(defengine youtube
;:keybinding "y"

(defengine visual-hunt
:docstring "Searchin' Visual Hunt For Images."
);end visualhunt

(defengine pxhere
:docstring "Searchin' pxhere For Images."
);end pxhere

;custom function print buffer in browser.
(defun print-buffer-to-browser ()
  (browse-url-of-buffer (htmlize-buffer)))

;custom function print region to browser
(defun print-region-to-browser ()
(if (use-region-p)
        (setq beg (region-beginning)
              end (region-end)))
(browse-url-of-buffer (htmlize-region beg end)))

;generate title for hydra
(defvar browser-title (with-octicon "globe" "USE BROWSER"))
("<C-m> b" . Browse-Web_/body)

(Browse-Web_ (:color blue :quit-key "q" :title browser-title)
          "Search Engines"
          (("d" engine/search-duckduckgo         "Duckduckgo")
           ("g" engine/search-google                 "Google")
           ("i" engine/search-google-images   "Google-images")
           ("m" engine/search-google-maps       "Google-maps")
           ("v" engine/search-visual-hunt       "Visual Hunt")
           ("3" engine/search-pxhere                 "PXHERE")
           ("e" helm-google-suggest   "Google Suggest in Helm")
);end search

          (("w" engine/search-wikipedia "Wikipedia")
           ("b" engine/search-github          "Github")
           ("s" engine/search-stack-overflow   "Stack Over Flow")
           ("y" engine/search-youtube      "Youtube")
           ("x" xah-open-in-external-app "Open File in default file program")
;          ("c" engine/search-soundcloud "Search Sound Cloud" )
);end other

          "Send Local Files To Browser"
          (("u" browse-url "Browse URL At Point")
           ("P" print-buffer-to-browser   "Print Buffer To Browser")
           ("p" print-region-to-browser   "Print Region To Browser")
           ("e" browse-url-of-buffer   "Render Buffer With Browser")
           ("h" hydra-helm/body "Return To Helm" :color blue )
           ("<SPC>" nil "QUIT" :color blue ));end local
);end heads
);end browse-web hydra
);end use-package engine-mode

emacs posiedon configuration browser hydra code

That’s all for now…