camlspotter avatar camlspotter committed 70ef387

offside trap is now disabled when the cursor is at an empty line

Comments (0)

Files changed (1)

 ;; point must be at the place where the future head of the indentation
 (defun offside-trap-find-sticky-lines ()
   (setq result (line-number-at-pos))
-  (let ((min-indent (current-column)))
-    ;; (message (format "min-indent %d" min-indent))
-    (save-excursion
-      ;; skip skippy lines at the head
-      (if (not (offside-trap-skip-sticky-skip-lines))
-	  ;; the first line is always sticky
-	  (forward-line 1))
-      (while
-	  (if (offside-trap-skip-sticky-skip-lines)
-	      (not (= (point-at-eol) (point-max)))
-	    (if (offside-trap-is-sticky-line min-indent)
-		(progn
-		  (setq result (line-number-at-pos))
-		  (if (= (point-at-eol) (point-max)) nil
-		    (forward-line 1)
-		    t))
-	      nil)))))
-  result)
+  ;; if the line is empty, no search
+  (if (offside-trap-empty-line) result
+
+    ;; if not empty
+    (let ((min-indent (current-column)))
+      ;; (message (format "min-indent %d" min-indent))
+      (save-excursion
+	;; skip skippy lines at the head
+	(if (not (offside-trap-skip-sticky-skip-lines))
+	    ;; the first line is always sticky
+	    (forward-line 1))
+	(while
+	    (if (offside-trap-skip-sticky-skip-lines)
+		(not (= (point-at-eol) (point-max)))
+	      (if (offside-trap-is-sticky-line min-indent)
+		  (progn
+		    (setq result (line-number-at-pos))
+		    (if (= (point-at-eol) (point-max)) nil
+		      (forward-line 1)
+		      t))
+		nil)))))
+    result))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; the trap
 
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.