Browse Source

Fix a longstanding issue with ellispsis on top of the window

* org.el (org-show-context): Remove useless catch.  Make sure the
top of the window is a visible headline.
* org.el (org-activate-plain-links): Remove unused catch.

* org-macs.el (org-get-alist-option): Return nil, not (nil), so
that `org-show-context' DTRT.

Thanks to Samuel Wales for his patience in reporting this.
Bastien Guerry 12 years ago
parent
commit
41882a99d3
2 changed files with 36 additions and 37 deletions
  1. 1 1
      lisp/org-macs.el
  2. 35 36
      lisp/org.el

+ 1 - 1
lisp/org-macs.el

@@ -263,7 +263,7 @@ in `org-rm-props'."
   (cond ((eq key t) t)
   (cond ((eq key t) t)
 	((eq option t) t)
 	((eq option t) t)
 	((assoc key option) (cdr (assoc key option)))
 	((assoc key option) (cdr (assoc key option)))
-	(t (cdr (assq 'default option)))))
+	(t (delq nil (cdr (assq 'default option))))))
 
 
 (defsubst org-check-external-command (cmd &optional use no-error)
 (defsubst org-check-external-command (cmd &optional use no-error)
   "Check if external program CMD for USE exists, error if not.
   "Check if external program CMD for USE exists, error if not.

+ 35 - 36
lisp/org.el

@@ -5303,21 +5303,20 @@ will be prompted for."
 
 
 (defun org-activate-plain-links (limit)
 (defun org-activate-plain-links (limit)
   "Run through the buffer and add overlays to links."
   "Run through the buffer and add overlays to links."
-  (catch 'exit
-    (let (f)
-      (when (and (re-search-forward (concat org-plain-link-re) limit t)
-		 (not (org-in-src-block-p)))
-	(org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
-	(setq f (get-text-property (match-beginning 0) 'face))
-	(unless (or (org-in-src-block-p)
-		    (eq f 'org-tag)
-		    (and (listp f) (memq 'org-tag f)))
-	  (add-text-properties (match-beginning 0) (match-end 0)
-			       (list 'mouse-face 'highlight
-				     'face 'org-link
-				     'keymap org-mouse-map))
-	  (org-rear-nonsticky-at (match-end 0)))
-	t))))
+  (let (f)
+    (when (and (re-search-forward (concat org-plain-link-re) limit t)
+	       (not (org-in-src-block-p)))
+      (org-remove-flyspell-overlays-in (match-beginning 0) (match-end 0))
+      (setq f (get-text-property (match-beginning 0) 'face))
+      (unless (or (org-in-src-block-p)
+		  (eq f 'org-tag)
+		  (and (listp f) (memq 'org-tag f)))
+	(add-text-properties (match-beginning 0) (match-end 0)
+			     (list 'mouse-face 'highlight
+				   'face 'org-link
+				   'keymap org-mouse-map))
+	(org-rear-nonsticky-at (match-end 0)))
+      t)))
 
 
 (defun org-activate-code (limit)
 (defun org-activate-code (limit)
   (if (re-search-forward "^[ \t]*\\(:\\(?: .*\\|$\\)\n?\\)" limit t)
   (if (re-search-forward "^[ \t]*\\(:\\(?: .*\\|$\\)\n?\\)" limit t)
@@ -12845,27 +12844,27 @@ How much context is shown depends upon the variables
 	(following-p (org-get-alist-option org-show-following-heading key))
 	(following-p (org-get-alist-option org-show-following-heading key))
 	(entry-p     (org-get-alist-option org-show-entry-below key))
 	(entry-p     (org-get-alist-option org-show-entry-below key))
 	(siblings-p  (org-get-alist-option org-show-siblings key)))
 	(siblings-p  (org-get-alist-option org-show-siblings key)))
-    (catch 'exit
-      ;; Show heading or entry text
-      (if (and heading-p (not entry-p))
-	  (org-flag-heading nil)    ; only show the heading
-	(and (or entry-p (outline-invisible-p) (org-invisible-p2))
-	     (org-show-hidden-entry)))    ; show entire entry
-      (when following-p
-	;; Show next sibling, or heading below text
-	(save-excursion
-	  (and (if heading-p (org-goto-sibling) (outline-next-heading))
-	       (org-flag-heading nil))))
-      (when siblings-p (org-show-siblings))
-      (when hierarchy-p
-	;; show all higher headings, possibly with siblings
-	(save-excursion
-	  (while (and (condition-case nil
-			  (progn (org-up-heading-all 1) t)
-			(error nil))
-		      (not (bobp)))
-	    (org-flag-heading nil)
-	    (when siblings-p (org-show-siblings))))))))
+    ;; Show heading or entry text
+    (if (and heading-p (not entry-p))
+	(org-flag-heading nil)    ; only show the heading
+      (and (or entry-p (outline-invisible-p) (org-invisible-p2))
+	   (org-show-hidden-entry)))    ; show entire entry
+    (when following-p
+      ;; Show next sibling, or heading below text
+      (save-excursion
+	(and (if heading-p (org-goto-sibling) (outline-next-heading))
+	     (org-flag-heading nil))))
+    (when siblings-p (org-show-siblings))
+    (when hierarchy-p
+      ;; show all higher headings, possibly with siblings
+      (save-excursion
+	(while (and (condition-case nil
+			(progn (org-up-heading-all 1) t)
+		      (error nil))
+		    (not (bobp)))
+	  (org-flag-heading nil)
+	  (when siblings-p (org-show-siblings)))))
+    (save-excursion (goto-char (window-start)) (recenter 0))))
 
 
 (defvar org-reveal-start-hook nil
 (defvar org-reveal-start-hook nil
   "Hook run before revealing a location.")
   "Hook run before revealing a location.")