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?

  • 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. – DoMiNeLa10 Jun 28 at 16:49
  • Thanks @DoMiNeLa10, so we'll have a look at widget.el. – ErikMD Jun 28 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 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 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 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.