 `doom/backward-delete-whitespace-to-column' otherwise."
   (interactive)
   (save-match-data
-    (cond ((doom--surrounded-p)
-           (let ((whitespace-match (match-string 1)))
-             (cond ((not whitespace-match)
-                    (call-interactively #'delete-backward-char))
-                   ((string-match "\n" whitespace-match)
-                    (funcall (if (featurep 'evil) #'evil-delete #'delete-region)
-                             (point-at-bol) (point))
-                    (call-interactively #'delete-backward-char)
-                    (save-excursion (call-interactively #'delete-char)))
-                   (t (just-one-space 0)))))
-          (t
-           (doom/backward-delete-whitespace-to-column)))))
+    (if (doom--surrounded-p)
+        (let ((whitespace-match (match-string 1)))
+          (cond ((not whitespace-match)
+                 (call-interactively #'delete-backward-char))
+                ((string-match "\n" whitespace-match)
+                 (funcall (if (featurep 'evil)
+                              #'evil-delete
+                            #'delete-region)
+                          (point-at-bol) (point))
+                 (call-interactively #'delete-backward-char)
+                 (save-excursion (call-interactively #'delete-char)))
+                (t (just-one-space 0))))
+      (doom/backward-delete-whitespace-to-column))))
 
 ;;;###autoload
 (defun doom/newline-and-indent ()

             (save-match-data
               (if (string-match "\\w*\\(\\s-+\\)$"
                                 (buffer-substring-no-properties (max (point-min) (- p movement)) p))
                   (sp-delete-char (- 0 (- (match-end 1) (match-beginning 1))))
                 (call-interactively delete-backward-char)))))

          ;; Otherwise do a regular delete

    (untabify beg end)))

;;;###autoload
(defun doom|enable-delete-trailing-whitespace ()
  "Attaches `delete-trailing-whitespace' to a buffer-local `before-save-hook'."
  (add-hook 'before-save-hook #'delete-trailing-whitespace nil t))


