How to get clickable text that invokes a functionTrigger a button click with JavaScript on the Enter key in a text boxGetting Emacs to untabify when saving certain file types (and only those file types)How to achieve code folding effects in Emacs?How do I make Git use the editor of my choice for commits?How to create an HTML button that acts like a link?In Emacs, is there a way to Call Interactive Function non-interactively from init.el?order of calling expressions within a defun*Insert text string into ido minibuffer using non-interactive defunEmacs: fill all text except indicated regionsHow can I open a long list of files from within emacs

What do you call a flexible diving platform?

How to apply the changes to my `.zshrc` file after edit?

Use cases for M-0 & C-0?

Why is it considered Acid Rain with pH <5.6

To find islands of 1 and 0 in matrix

3D Statue Park: Daggers and dashes

How to judge a Ph.D. applicant that arrives "out of thin air"

Did the IBM PC use the 8088's NMI line?

Decreasing star count

Why/when is AC-DC-AC conversion superior to direct AC-AC conversion?

Recommendations or Experiences on Archiving Mailing Data

Why force the nose of 737 Max down in the first place?

Why isn't there a serious attempt at creating a third mass-appeal party in the US?

Commercial jet accompanied by small plane near Seattle

What is the most common end of life issue for a car?

If Trump gets impeached, how long would Pence be president?

Examples of simultaneous independent breakthroughs

Help with one interview question --expected length of numbers drawn

Converting 8V AC to 8V DC - bridge rectifier gets very hot while idling

Writing a clean implementation of rock–paper–scissors game in C++

Request for a Latin phrase as motto "God is highest/supreme"

Craving for food?

Why did House of Representatives need to condemn Trumps Tweets?

Why does Canada require mandatory bilingualism in all government posts?



How to get clickable text that invokes a function


Trigger a button click with JavaScript on the Enter key in a text boxGetting Emacs to untabify when saving certain file types (and only those file types)How to achieve code folding effects in Emacs?How do I make Git use the editor of my choice for commits?How to create an HTML button that acts like a link?In Emacs, is there a way to Call Interactive Function non-interactively from init.el?order of calling expressions within a defun*Insert text string into ido minibuffer using non-interactive defunEmacs: fill all text except indicated regionsHow can I open a long list of files from within emacs






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















Let's say I have the following text in the buffer



CMM-3: Description
CMM-91: Description 2


I want the CMM-XX to become clickable areas that invoke a custom function



(defun jira-ticket-view (&optional jira-ticket)
"Open Jira Ticket Inside Emacs"
(interactive)
....)


How this can be achieved in emacs/elisp?










share|improve this question
























  • Org mode is the first thing that comes to mind; You might consider checking the source for their link handling.

    – 0x5453
    Mar 26 at 19:03

















1















Let's say I have the following text in the buffer



CMM-3: Description
CMM-91: Description 2


I want the CMM-XX to become clickable areas that invoke a custom function



(defun jira-ticket-view (&optional jira-ticket)
"Open Jira Ticket Inside Emacs"
(interactive)
....)


How this can be achieved in emacs/elisp?










share|improve this question
























  • Org mode is the first thing that comes to mind; You might consider checking the source for their link handling.

    – 0x5453
    Mar 26 at 19:03













1












1








1








Let's say I have the following text in the buffer



CMM-3: Description
CMM-91: Description 2


I want the CMM-XX to become clickable areas that invoke a custom function



(defun jira-ticket-view (&optional jira-ticket)
"Open Jira Ticket Inside Emacs"
(interactive)
....)


How this can be achieved in emacs/elisp?










share|improve this question
















Let's say I have the following text in the buffer



CMM-3: Description
CMM-91: Description 2


I want the CMM-XX to become clickable areas that invoke a custom function



(defun jira-ticket-view (&optional jira-ticket)
"Open Jira Ticket Inside Emacs"
(interactive)
....)


How this can be achieved in emacs/elisp?







button emacs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 0:20









Drew

24.7k5 gold badges53 silver badges75 bronze badges




24.7k5 gold badges53 silver badges75 bronze badges










asked Mar 26 at 18:37









DmitrySemenovDmitrySemenov

3,6913 gold badges30 silver badges41 bronze badges




3,6913 gold badges30 silver badges41 bronze badges












  • Org mode is the first thing that comes to mind; You might consider checking the source for their link handling.

    – 0x5453
    Mar 26 at 19:03

















  • Org mode is the first thing that comes to mind; You might consider checking the source for their link handling.

    – 0x5453
    Mar 26 at 19:03
















Org mode is the first thing that comes to mind; You might consider checking the source for their link handling.

– 0x5453
Mar 26 at 19:03





Org mode is the first thing that comes to mind; You might consider checking the source for their link handling.

– 0x5453
Mar 26 at 19:03












1 Answer
1






active

oldest

votes


















5














Create a new keymap, bind mouse-1 to the function you want to call, and add the keymap to the link text as a text property. Set mouse-face to highlight and add help-echo for extra user-friendliness - those take effect when the user hovers the mouse pointer over the text.



(defun my-function ()
(interactive)
(message "You've clicked the text!"))

(let ((map (make-sparse-keymap)))
(define-key map [mouse-1] 'my-function)
(insert "Foo: "
(propertize "bar" 'keymap map 'mouse-face 'highlight 'help-echo "Click here!")
"n"))


See the section Clickable text in the elisp reference manual for more information.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364126%2fhow-to-get-clickable-text-that-invokes-a-function%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    5














    Create a new keymap, bind mouse-1 to the function you want to call, and add the keymap to the link text as a text property. Set mouse-face to highlight and add help-echo for extra user-friendliness - those take effect when the user hovers the mouse pointer over the text.



    (defun my-function ()
    (interactive)
    (message "You've clicked the text!"))

    (let ((map (make-sparse-keymap)))
    (define-key map [mouse-1] 'my-function)
    (insert "Foo: "
    (propertize "bar" 'keymap map 'mouse-face 'highlight 'help-echo "Click here!")
    "n"))


    See the section Clickable text in the elisp reference manual for more information.






    share|improve this answer



























      5














      Create a new keymap, bind mouse-1 to the function you want to call, and add the keymap to the link text as a text property. Set mouse-face to highlight and add help-echo for extra user-friendliness - those take effect when the user hovers the mouse pointer over the text.



      (defun my-function ()
      (interactive)
      (message "You've clicked the text!"))

      (let ((map (make-sparse-keymap)))
      (define-key map [mouse-1] 'my-function)
      (insert "Foo: "
      (propertize "bar" 'keymap map 'mouse-face 'highlight 'help-echo "Click here!")
      "n"))


      See the section Clickable text in the elisp reference manual for more information.






      share|improve this answer

























        5












        5








        5







        Create a new keymap, bind mouse-1 to the function you want to call, and add the keymap to the link text as a text property. Set mouse-face to highlight and add help-echo for extra user-friendliness - those take effect when the user hovers the mouse pointer over the text.



        (defun my-function ()
        (interactive)
        (message "You've clicked the text!"))

        (let ((map (make-sparse-keymap)))
        (define-key map [mouse-1] 'my-function)
        (insert "Foo: "
        (propertize "bar" 'keymap map 'mouse-face 'highlight 'help-echo "Click here!")
        "n"))


        See the section Clickable text in the elisp reference manual for more information.






        share|improve this answer













        Create a new keymap, bind mouse-1 to the function you want to call, and add the keymap to the link text as a text property. Set mouse-face to highlight and add help-echo for extra user-friendliness - those take effect when the user hovers the mouse pointer over the text.



        (defun my-function ()
        (interactive)
        (message "You've clicked the text!"))

        (let ((map (make-sparse-keymap)))
        (define-key map [mouse-1] 'my-function)
        (insert "Foo: "
        (propertize "bar" 'keymap map 'mouse-face 'highlight 'help-echo "Click here!")
        "n"))


        See the section Clickable text in the elisp reference manual for more information.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 28 at 13:40









        legoscialegoscia

        30.4k12 gold badges87 silver badges120 bronze badges




        30.4k12 gold badges87 silver badges120 bronze badges
















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364126%2fhow-to-get-clickable-text-that-invokes-a-function%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript