1

We would like to devise an Emacs front-end that queries a back-end (generating a list of items in JSON format or so, each with a title, long description, and an URL), and displays this list in a special buffer, with a button to unhide the description, a button to trigger a specific Elisp action, and an hyperlink to browse the URL.

This question only focuses on the front-end part (not the communication with the back-end).

There are multiple modes that are close to this requirement, but each may have pros and cons, just to recapitulate:

  1. goto-address-mode → we could easily apply this mode and make the buffer read-only, but this would just render URLs as clickable hyperlinks (no formatting of the text or choice of the hyperlinks' caption).
  2. org-mode → we could easily generate a .org file and display it in read-only, but (1) the look-and-feel is not that of a browser (e.g., bold text is written *bold*, not bold) and (2) the Org syntax is much more expressive than what would be enough here.
  3. the *GNU Emacs* initial buffer → we could generate a similar buffer with custom text/hyperlinks and the rendering would be much better than the last two solutions (but maybe buttons and accordions are not available).
  4. Custom-mode → displaying the list of items in a buffer similar to M-x customize would be great, as it would have an optimal look-and-feel; but we are unsure if it is feasible to "create a custom Custom-mode buffer" without the "customization" feature (but with actions such as URL opening).

So would you have pointers or suggestions regarding how to generate buffers implementing the solution 4. above?

ErikMD
  • 126
  • 5
  • 1
    You might want to take a look at `widget.el`, which is used by `customize`. Emacs provides a JSON parser in the `json` feature. You might get away with defining your own custom mode, and just inserting buttons and propertized content into a buffer. The mode could be derived from something like `view-mode`, and you can create your own keymap. –  Jun 28 '19 at 16:49
  • Thanks @DoMiNeLa10, so we'll have a look at `widget.el`. – ErikMD Jun 28 '19 at 16:55
  • Anyway if we'd want to switch to a fully custom mode derived from `view-mode`, is it easy to add buttons without using `widget.el`? (BTW @DoMiNeLa10 feel free to post your initial comment as an answer if you want to be credited with a vote :) – ErikMD Jun 28 '19 at 17:06
  • 2
    This question is too broad. emacs.SE is not really the right place for opinions or discussion about the pros and cons of different possible design options. Questions here should typically be specific, looking for specific (typically how-to) answers. – Drew Jun 28 '19 at 18:03
  • Thanks @Drew for your comment. I was aware of the emacs.SE requirement to ask questions not too broad, so I tried to give enough details to delimit my question as much as possible, which basically amounts to "is it technically feasible to implement the solution 4." and DoMiNeLa10's feedback was very useful :-) − [Anyway feel free to comment further if you have suggestions for some reformulation of my question, or other places on StackExchange where yet more design-oriented elisp questions can be asked.] – ErikMD Jun 28 '19 at 18:26
  • @Drew do you think this should be moved to chat? –  Jun 28 '19 at 20:12
  • @DoMiNeLa10: Not for my benefit - I've said what I wanted to say. If someone wants to edit the question to ask only how to implement "solution 4", and if the result of that edit can be clear and specific enough to solicit a useful answer, then please consider doing that. I voted to close it as it is now, but it is still open. My suggestion to OP is to pose such a question on a site such as Reddit, which solicits discussion and brainstorming. I think that might be more helpful for OP. – Drew Jun 28 '19 at 22:34
  • Thanks @Drew; so I rephrased my question accordingly. – ErikMD Jun 28 '19 at 23:23
  • IMHO, there are still multiple questions here, and you are still fishing for brainstorming/design suggestions for them. A specific question would be something like, "How do I implement a button to trigger a specific Elisp action?". And even then it would be helpful to see what you've already tried (code). I do think you'd get lots of help of the kind you're looking for on a site like Reddit, however. It's not that your investigation isn't interesting; it's that it's too broad for emacs.SE (IMHO). – Drew Jun 29 '19 at 14:39

0 Answers0