      (move-to-selection (calc-position tooltip.offsetWidth tooltip.offsetHeight)))))
 
 
-;;;; Include listener for tooltips
+;; -----------------------------------------------------------------------------
+;; Selection corrections
+
+(defn- snap-selection
+  "Selection optimizations. Snaps to a specific pattern. Currently selects the
+  whole sentence, where the selected parts are part of."
+  []
+  (let [sel (js/document.getSelection)]
+    (when (-> sel str count pos?)
+      (.modify sel "move"   "backward" "sentence")
+      (.modify sel "extend" "forward"  "sentence")
+      (.modify sel "extend" "backward" "character")
+      sel)))
+
+(defn- save-selected-text
+  "Get the user's selection and save it."
+  []
+  (let [selection (snap-selection)]
+    (if-not (nil? selection)
+      (do (move-to-selection)
+          (lib/save-selection! (str selection)))
+      (hide))))
+
 (defn- listen
   "Helper function for mouse-click events."
   [el type]

  (let [offset 5]
    (+ (- top theight offset) js/window.scrollY)))

(defn calc-position
  "Create a new tooltip at given selection. Creates a rectangle around the selection,
   which has position-properties and which are useful for positioning of the tooltip."
  [tooltip-width tooltip-height]

    (events/listen el type (fn [e] (put! out e)))
    out))

(defn- track-user-selection
  "Listen to clicks on the websites' text to store it in the app-state."
  []
  (when-let [discuss-text-dom (gdom/getElement (lib/prefix-name "text"))]
