emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Christopher J. White" <orgmode@grierwhite.com>
To: emacs-orgmode@gnu.org
Subject: Re: org-link minor mode
Date: Tue, 14 Aug 2012 06:57:31 -0400	[thread overview]
Message-ID: <502A2F1B.5030507@grierwhite.com> (raw)
In-Reply-To: <CAOXM+eX-xkGu4B8c=9RLQ+959Sn050wtqSHO2fqhFQX4X5c53A@mail.gmail.com>

This is pretty cool, Sean.  One issue I'm having is that it does not 
properly handle "breaking" the link:

"[[link][description]]" is displayed as "link", with the cursor after 
link.  In org-mode, if I hit backspace, it deletes the trailing ']' and 
changes the display to "[[link][description]".  But using this minor 
mode, it keeps still just shows "link".  If I turn minor mode off again, 
it's clear that the trailing bracket was deleted.

I took a look at the org source regarding links, but I couldn't quite 
figure out how org does this.  It just calls org-delete-backward-char, 
which doesn't appear to have any magic for links.

Thanks
...cj


On 8/12/12 4:25 PM, Sean O'Halpin wrote:
> Hi,
>
> I've been hacking this weekend to try to create a minor mode that
> enables org-mode bracket links in modes other than org-mode.
>
> I believe this has been mooted before
> (e.g. 
> http://lists.gnu.org/archive/html/emacs-orgmode/2009-08/msg00573.html).
>
> The following codes works for me but I'm sure it could be improved.
>
> I'm an elisp noob so I'd very much appreciate feedback on the approach
> I'm taking.  For example, I'm not sure how to prevent turning on
> org-link-minor-mode from an org-mode buffer - advice would be welcome.
>
> Regards,
> Sean
>
> #+begin_src emacs-lisp
>
> (require 'org)
>
> (define-minor-mode org-link-minor-mode
>    "Toggle display of org-mode style bracket links in non-org-mode 
> buffers."
>    :lighter " org-link"
>    (let ((org-link-minor-mode-keywords (list
> '(org-activate-bracket-links (0 'org-link t)))))
>      (save-excursion
>        (save-match-data
>          (goto-char (point-min))
>          (if org-link-minor-mode
>              (progn
>                (font-lock-add-keywords nil org-link-minor-mode-keywords t)
>                (set (make-local-variable 'org-descriptive-links)
> org-descriptive-links)
>                (if org-descriptive-links (add-to-invisibility-spec 
> '(org-link)))
>                (font-lock-fontify-buffer)
>                )
>            (progn
>              (font-lock-remove-keywords nil org-link-minor-mode-keywords)
>              (org-remove-from-invisibility-spec '(org-link))
>              (while (re-search-forward org-bracket-link-regexp nil t)
>                ;; Remove all org-link properties
>                (remove-text-properties (match-beginning 0) (match-end
> 0) (text-properties-at (match-beginning 0)))
>                )
>              )
>            )))))
>
> (provide 'org-link-minor-mode)
>
> #+end_src
>
>

  parent reply	other threads:[~2012-08-14 10:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-12 20:25 org-link minor mode Sean O'Halpin
2012-08-14  7:49 ` Bastien
2012-08-18  4:07   ` Sean O'Halpin
2012-08-18 15:07     ` Bastien
2012-08-19 12:16       ` Sean O'Halpin
2012-08-14 10:57 ` Christopher J. White [this message]
2012-08-18  0:02   ` Sean O'Halpin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=502A2F1B.5030507@grierwhite.com \
    --to=orgmode@grierwhite.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).