emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole ad7a089 13/20: * hys-org.el (defib org-mode,


From: Robert Weiner
Subject: [elpa] externals/hyperbole ad7a089 13/20: * hys-org.el (defib org-mode, org-mode:help): Ensured trigger only in org-mode and simplified logic.
Date: Tue, 9 Aug 2016 19:17:08 +0000 (UTC)

branch: externals/hyperbole
commit ad7a0895431cdd61e4e64f430c406eb3fbdba5e1
Author: Bob Weiner <address@hidden>
Commit: Bob Weiner <address@hidden>

    * hys-org.el (defib org-mode, org-mode:help): Ensured trigger only in 
org-mode and simplified logic.
                 (org-heading-at-p): Deleted and used org-at-heading-p instead.
    
    * hpath.el (hpath:to-markup-anchor): Generalized to work in any HTML buffer 
based on major mode, not file suffix.
               (hpath:html-suffix-regexp): Removed, no longer used.
---
 Changes       |    6 ++++++
 HY-NEWS       |    3 +++
 hmouse-key.el |    5 ++---
 hpath.el      |   29 ++++++++++++++---------------
 hsys-org.el   |   40 ++++++++++++++++++++--------------------
 hui-mouse.el  |    2 +-
 6 files changed, 46 insertions(+), 39 deletions(-)

diff --git a/Changes b/Changes
index 18b58de..3576069 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,12 @@
 
 2016-08-08  Bob Weiner  <address@hidden>
 
+* hys-org.el (defib org-mode, org-mode:help): Ensured trigger only in org-mode 
and simplified logic.
+             (org-heading-at-p): Deleted and used org-at-heading-p instead.
+
+* hpath.el (hpath:to-markup-anchor): Generalized to work in any HTML buffer 
based on major mode, not file suffix.
+           (hpath:html-suffix-regexp): Removed, no longer used.
+
 * hmouse-tag.el (smart-asm-include-file, smart-c-include-file): Simplified 
conditionals a bit.
 
 * hpath.el (hpath:is-p): Fixed improper parsing issue with hash links that 
included commas such as:
diff --git a/HY-NEWS b/HY-NEWS
index 3a7266e..ec5b863 100644
--- a/HY-NEWS
+++ b/HY-NEWS
@@ -35,6 +35,9 @@
       hash link references are not matched as social hash tags.  Made the list
       of modes a variable, hibtypes-social-inhibit-modes.
 
+    - org-mode Implicit Button Type: Improved to invoke org-meta-return when
+      not on an Org link or outline heading.
+
   DOCUMENTATION
 
     - Added pointer to HyControl video and {C-c \} binding which invokes
diff --git a/hmouse-key.el b/hmouse-key.el
index e4850d3..f63735b 100644
--- a/hmouse-key.el
+++ b/hmouse-key.el
@@ -36,9 +36,8 @@
   ;; XEmacs and Emacs pre-load their mouse libraries, so
   ;; we shouldn't have to require them here.
   (eval (cdr (assoc (hyperb:window-system)
-                   '(
-                     ("xterm"   . (require 'x-mouse))   ; X
-                     ("next"    . (load "eterm-fns" t)) ; NeXTstep
+                   '(("xterm"   . (require 'x-mouse))   ; X
+                     ("next"    . (load "eterm-fns" t)) ; NEXTSTEP
                      )))))
 
 ;;; ************************************************************************
diff --git a/hpath.el b/hpath.el
index 3de5a63..609da6e 100644
--- a/hpath.el
+++ b/hpath.el
@@ -17,6 +17,7 @@
 ;;; ************************************************************************
 
 (require 'hversion) ;; for (hyperb:window-system) definition
+(require 'hui-select) ;; for `hui-select-markup-modes'
 
 (unless (fboundp 'br-in-browser)
     ;; Then the OO-Browser is not loaded, so we can never be within the
@@ -284,9 +285,6 @@ use with string-match.")
 (defconst hpath:html-anchor-id-pattern "\\(id\\|name\\)=['\"]%s['\"]?"
   "Regexp matching an html anchor id definition and containing a %s for 
replacement of a specific anchor id.")
 
-(defconst hpath:html-suffix-regexp "\\.[a-zA-Z]*[hH[tT][mM][a-zA-Z0-9]*"
-  "Regexp that matches to any common html file suffix.")
-
 (defconst hpath:markdown-anchor-id-pattern "^[ ]*%s: "
   "Regexp matching a Markdown anchor id definition and containing a %s for 
replacement of a specific anchor id.")
 
@@ -651,8 +649,8 @@ program)."
 (defun hpath:to-markup-anchor (hash anchor)
   "Move point to the definition of ANCHOR if found or if only HASH is non-nil, 
move to the beginning of the buffer."
   (cond ((and (stringp anchor) (not (string-empty-p anchor)))
-        (cond ((string-match hpath:html-suffix-regexp buffer-file-name)
-               ;; HTML link ids are case-sensitive.
+        (cond ((memq major-mode hui-select-markup-modes)
+               ;; In HTML-like mode where link ids are case-sensitive.
                (let ((opoint (point))
                      (case-fold-search))
                  (goto-char (point-min))
@@ -780,12 +778,12 @@ nonexistent local paths are allowed."
         ;; Path may be a link reference with components other than a
         ;; pathname.  These components always follow a comma or # symbol, so
         ;; strip them, if any, before checking path.
-        (if (string-match "[ \t\n\r]*," path)
-            (setq rtn-path (concat (substring path 0 (match-beginning 0))
-                                    "%s" (substring path (match-beginning 0)))
-                  path (substring path 0 (match-beginning 0)))
+        (if (string-match "\\`[^#][^#,]*\\([ \t\n\r]*[#,]\\)" path)
+            (setq rtn-path (concat (substring path 0 (match-beginning 1))
+                                    "%s" (substring path (match-beginning 1)))
+                  path (substring path 0 (match-beginning 1)))
           (setq rtn-path (concat rtn-path "%s")))
-        ;; If path is just a local HTML reference that begins with #,
+        ;; If path is just a local reference that begins with #,
         ;; prepend the file name to it.
         (cond ((and buffer-file-name
                     ;; ignore HTML color strings
@@ -841,13 +839,14 @@ nonexistent local paths are allowed."
                             (file-directory-p path))
                            (t))))
               (progn
-                ;; Quote any but last %s within rtn-path.
+                ;; Quote any %s except for one at the end of the path
+                ;; part of rtn-path (immediately preceding a # or ,
+                ;; character or the end of string).
                 (setq rtn-path (hypb:replace-match-string "%s" rtn-path "%%s")
-                      rtn-path (hypb:replace-match-string "%%s\\'" rtn-path 
"%s"))
+                      rtn-path (hypb:replace-match-string 
"%%s\\([#,]\\|\\'\\)" rtn-path "%s\\1"))
                 ;; Return path if non-nil return value.
-                (if (stringp suffix);; suffix could = t, which we ignore
-                    (if (string-match
-                         (concat (regexp-quote suffix) "%s") rtn-path)
+                (if (stringp suffix) ;; suffix could = t, which we ignore
+                    (if (string-match (concat (regexp-quote suffix) "%s") 
rtn-path)
                         ;; remove suffix
                         (concat (substring rtn-path 0 (match-beginning 0))
                                 (substring rtn-path (match-end 0)))
diff --git a/hsys-org.el b/hsys-org.el
index 55c9635..f9604db 100644
--- a/hsys-org.el
+++ b/hsys-org.el
@@ -13,7 +13,8 @@
 ;;
 ;;   This defines a context-sensitive implicit button type, org-mode, triggered
 ;;   when the major mode is org-mode and point is anywhere other than
-;;   the end of a line.  When:
+;;   the end of a line.
+;;   When:
 ;;     on an Org mode link - displays the link referent
 ;;     on an Org mode heading - cycles through the available display
 ;;       views for that heading
@@ -25,6 +26,7 @@
 ;;; ************************************************************************
 
 (require 'hbut)
+(require 'org)
 
 ;;; ************************************************************************
 ;;; Public Button Types
@@ -35,21 +37,23 @@
 The variable, `browse-url-browser-function', customizes the url browser that
 is used for urls.  Valid values of this variable include 
`browse-url-default-browser'
 and `browse-url-generic'."
-  (cond ((org-link-at-p)
-        (hact 'org-link nil))
-       ((org-heading-at-p)
-        (hact 'org-cycle nil))
-       (t (hact 'org-meta-return))))
+  (when (eq major-mode 'org-mode)
+    (cond ((org-link-at-p)
+          (hact 'org-link nil))
+         ((org-at-heading-p)
+          (hact 'org-cycle nil))
+         (t (hact 'org-meta-return)))))
 
 (defun org-mode:help (&optional _but)
   "If on an Org mode heading, cycles through views of the whole buffer outline.
 If on an Org mode link, displays standard Hyperbole help."
-  (cond ((and (org-heading-at-p) (not (org-link-at-p)))
-        (org-global-cycle nil))
-       ;; Shows help for an Org mode link; if not on a link, this
-       ;; will not be called.
-       (t (hkey-help current-prefix-arg)))
-  t)
+  (when (eq major-mode 'org-mode)
+    (cond ((org-link-at-p)
+          (hkey-help current-prefix-arg)
+          t)
+         ((org-at-heading-p)
+          (org-global-cycle nil)
+          t))))
 
 (defact org-link (link)
   "Follows an Org mode LINK.  If LINK is nil, follows the link at point."
@@ -61,15 +65,11 @@ If on an Org mode link, displays standard Hyperbole help."
 ;;; Public functions
 ;;; ************************************************************************
 
-(defun org-heading-at-p ()
-  (require 'org)
-  (and (eq major-mode 'org-mode) (org-at-heading-p)))
-
+;; Assumes caller has already checked that the current buffer is in org-mode.
 (defun org-link-at-p ()
-  (and (eq major-mode 'org-mode)
-       (let ((face-prop (get-text-property (point) 'face)))
-        (or (eq face-prop 'org-link)
-            (and (listp face-prop) (memq 'org-link face-prop))))))
+  (let ((face-prop (get-text-property (point) 'face)))
+    (or (eq face-prop 'org-link)
+       (and (listp face-prop) (memq 'org-link face-prop)))))
 
 ;;; ************************************************************************
 ;;; Private functions
diff --git a/hui-mouse.el b/hui-mouse.el
index 1f79891..b56557f 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -20,7 +20,7 @@
 ;;  items and Hyperbole buttons, follow these instructions.
 ;;
 ;;  If you plan to use a mouse only with X windows (XEmacs, GNU Emacs
-;;  19, or InfoDock), Mac OS X, or NeXTSTEP, and you want to use the
+;;  19, or InfoDock), Mac OS X, or NEXTSTEP, and you want to use the
 ;;  shift-middle and shift-right buttons, you need not do any mouse
 ;;  configuration.  Your Emacs executable must have been built so as to
 ;;  include the mouse support files for your window system, however.  These



reply via email to

[Prev in Thread] Current Thread [Next in Thread]