button-lock

Homepage: http://github.com/rolandwalker/button-lock

Author: Roland Walker

Updated:

Summary

Clickable text defined by regular expression

Commentary

Quickstart

    (require 'button-lock)

    (global-button-lock-mode 1)

    (setq url-button (button-lock-set-button
                      "\\

    buttons.el
    Miles Bader 

Notes

    By default, button-lock uses newfangled left-clicks rather than
    Emacs-traditional middle clicks.

    Font lock is very efficient, but it is still possible to bog
    things down if you feed it expensive regular expressions.  Use
    anchored expressions, and be careful about backtracking.  See
    `regexp-opt'.

    Some differences between button-lock.el and hi-lock.el:

        * The purpose of hi-lock.el is to change the _appearance_
          of keywords.  The purpose of button-lock is to change the
          _bindings_ on keywords.

        * Hi-lock also supports embedding new keywords in files,
          which is too risky of an approach for button-lock.

        * Hi-lock supports overlays and can work without font-lock.

    Some differences between button-lock.el and buttons.el

        * Buttons.el is for inserting individually defined
          buttons.  Button-lock.el is for changing all matching text
          into a button.

Compatibility and Requirements

    No external dependencies

Bugs

    Case-sensitivity of matches depends on how font-lock-defaults
    was called for the current mode (setting
    font-lock-keywords-case-fold-search).  So, it is safest to
    assume that button-lock pattern matches are case-sensitive --
    though they might not be.

    Return value for button-lock-register-global-button is inconsistent
    with button-lock-set-button.  The global function does not
    return a button which could be later passed to
    button-lock-extend-binding, nor are the arguments parsed and
    checked for validity.  Any errors for global buttons are also
    deferred until the mode is activated.

    This package is generally incompatible with interactive modes
    such as `comint-mode' and derivatives, due conflicting uses
    of the rear-nonsticky text property.  To change this, :rear-sticky
    can be set when `calling button-lock-set-button'.  See also
    https://github.com/rolandwalker/fixmee/issues/8#issuecomment-75397467 .

TODO

    Validate arguments to button-lock-register-global-button.
    maybe split set-button into create/set functions, where
    the create function does all validation and returns a
    button object.  Pass in button object to unset as well.

    Why are mouse and keyboard separate, can't mouse be passed
    through kbd macro?  The issue may have been just surrounding
    mouse events with "<>" before passing to kbd.

    Look into new syntax-propertize-function variable (Emacs 24.x).

    A refresh function to toggle every buffer?

    Peek into font-lock-keywords and deduplicate based on the
    stored patterns.

    Substitute a function for regexp to make properties invisible
    unless button-lock mode is on - esp for keymaps.

    Add predicate argument to button-set where predicate is
    evaluated during matcher.  This could be used to test for
    comment-only.

    Consider defining mode-wide button locks (pass the mode as the
    first argument of font-lock-add-keywords).  Could use functions
    named eg button-lock-set-modal-button.

    Add a language-specific navigation library (header files in C,
    etc).

    Example of exchanging text values on wheel event.

    Convenience parameters for right-click menus.

    Button-down visual effects as with Emacs widgets.

License

Simplified BSD License

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:

  1. Redistributions of source code must retain the above
     copyright notice, this list of conditions and the following
     disclaimer.

  2. Redistributions in binary form must reproduce the above
     copyright notice, this list of conditions and the following
     disclaimer in the documentation and/or other materials
     provided with the distribution.

Ths software is provided by Roland Walker "AS IS" and any express
or implied warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular
purpose are disclaimed.  In no event shall Roland Walker or
contributors be liable for any direct, indirect, incidental,
special, exemplary, or consequential damages (including, but not
limited to, procurement of substitute goods or services; loss of
use, data, or profits; or business interruption) however caused
and on any theory of liability, whether in contract, strict
liability, or tort (including negligence or otherwise) arising in
any way out of the use of this software, even if advised of the
possibility of such damage.

The views and conclusions contained in the software and
documentation are those of the authors and should not be
interpreted as representing official policies, either expressed
or implied, of Roland Walker.

Dependencies

Reverse dependencies