summaryrefslogtreecommitdiff
path: root/hib-social.el
diff options
context:
space:
mode:
authorBob Weiner <rsw@gnu.org>2016-08-05 19:03:24 -0400
committerBob Weiner <rsw@gnu.org>2016-08-05 19:03:24 -0400
commit1f27deb6ba8e909b2f01f970240d0ca3c32c5b5b (patch)
treeb24018d450c2dc5208212464daca7bfb914d7952 /hib-social.el
parent71b8e7368f9b1c78473943d6fd271df938f03aa7 (diff)
* hibtypes.el (annot-bib): Added markdown-mode to the excluded list to avoid conflict with its links.
(markdown-internal-link): Added to follow internal Markdown links. man/hyperbole.texi: (Implicit Buttons): Added markdown-internal-link. * hsys-www.el: Renamed from hsys-w3.el since it is not related to the Emacs W3 web browser any longer. * Demo (HTML and Markdown Hash Links): Added this section. hib-social.el (social-reference): Changed so disabled this implicit button type in html and related modes only if within double or single quotes. hibtypes.el (pathname): hpath.el (hpath:to-markup-anchor): Renamed from hpath:to-html-anchor and generalized for use with Markdown as well. Added recognition of section links like: - [Why was Hyperbole developed?](#why-was-hyperbole-developed) so the pathname implicit button type matches when the Action Key is pressed anywhere on or after the hash character and jumps to the section: ## Why was Hyperbole developed? accounting for any trailing punctuation and differences in case. (hpath:markdown-suffix-regexp, hpath:markdown-anchor-id-pattern, hpath:markdown-section-pattern): Added. (hpath:markup-link-anchor-regexp): Renamed from hpath:html-link-anchor-regexp.
Diffstat (limited to 'hib-social.el')
-rw-r--r--hib-social.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/hib-social.el b/hib-social.el
index 55d8fe3..62e441d 100644
--- a/hib-social.el
+++ b/hib-social.el
@@ -29,6 +29,7 @@
(eval-when-compile (require 'browse-url))
(require 'hbut)
+(require 'hargs)
;;; ************************************************************************
;;; Public variables
@@ -64,7 +65,7 @@
"Regular expression that matches a social media hashtag or username reference.
See `ibtypes::social-reference' for format details.")
-(defvar hibtypes-social-inhibit-modes '(html-mode web-mode xml-mode sgml-mode texinfo-mode para-mode)
+(defvar hibtypes-social-inhibit-modes '(texinfo-mode para-mode)
"*List of major modes in which to inhibit any possible social media tag matches.")
;;; ************************************************************************
@@ -80,8 +81,17 @@ Reference format is:
The first part of the label for a button of this type is the social
media service name. The service name defaults to the value of
`hibtypes-social-default-service' (default value of \"twitter\")
-when not given, so #hashtag would be the same as twitter#hashtag."
- (when (and (not (memq major-mode hibtypes-social-inhibit-modes))
+when not given, so #hashtag would be the same as twitter#hashtag.
+
+This will not match within any single line, single or
+double-quoted strings or within any buffer whose major mode is
+listed in `hibtypes-social-inhibit-modes'."
+ (when (and (not (or (memq major-mode hibtypes-social-inhibit-modes)
+ (hargs:delimited "\"" "\"")
+ (hargs:delimited "[\`\']" "\'" t)
+ ;; Avoid Markdown parenthesized hash links
+ (and (eq major-mode 'markdown-mode)
+ (hargs:delimited "(" ")"))))
(save-excursion
(if (looking-at "[#@._[:alnum:]]")
(skip-chars-backward "#@._[:alnum:]"))