-
I was wondering if anyone had any luck displaying images inside of Emacs inside of kitty. Is that even possible? If so, how can we do it? I wanted to display inline images in The function |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 2 replies
-
It looks like this requires the solution discussed in the following link. |
Beta Was this translation helpful? Give feedback.
-
Far better would be for someone to add support for the full kitty graphics protocol to emacs. https://sw.kovidgoyal.net/kitty/graphics-protocol/ |
Beta Was this translation helpful? Give feedback.
-
I sort of got what I wanted by writing a custom kitten that will create a new window and then cat the image that I want to see from Emacs. In Emacs, I only need to set a custom The kitten looks like below. I'm not sure if that's the best way to send a command to the other window. For instance, nothing happens if the pointer in the other window is in normal mode. How could I make sure that the command simply gets sent to the shell and executed? Also, # imgviewer.py
from typing import List
from pathlib import Path
from kitty.boss import Boss
from kittens.tui.handler import result_handler
def main(args: List[str]) -> str:
pass
@result_handler(no_ui=True)
def handle_result(args: List[str], result: None, target_window_id: int, boss: Boss) -> None:
args = args[1:]
files = []
w = boss.window_id_map.get(target_window_id)
for arg in args:
file = Path(arg).expanduser()
if file.exists():
files.append(file)
if len(files) == 0:
return
try:
imgviewer = next(boss.match_windows(f"title:imgviewer{w.id}"))
except StopIteration:
imgviewer = boss.launch("--window-title", f"imgviewer{w.id}",
"--cwd", "current", "--keep-focus")
imgviewer = next(boss.match_windows(f"title:imgviewer{w.id}"))
imgviewer.write_to_child("export HISTFILE=\r")
imgviewer.write_to_child(f"timg {' '.join(str(f) for f in files)}\r") And in Emacs, I add the following to the configuration file: (custom-set-variables
'(mailcap-user-mime-data '(("kitty @ kitten ./imgviewer.py %s" "image/png" nil)))) This is how it looks like: |
Beta Was this translation helpful? Give feedback.
-
You dont need to do any of that if you just want to open the image in a
new window. You can just do
(mailcap-user-mime-data '(("kitty kitty +kitten icat --hold %s"))'
|
Beta Was this translation helpful? Give feedback.
-
Ah cool. Note that this can be done purely by using the remote control
api without needing a kitten, but of course a kitten works as well.
|
Beta Was this translation helpful? Give feedback.
-
Chiming in with a huge thread about implementing kitty protocols on emacs https://lists.nongnu.org/archive/html/emacs-devel/2022-09/msg00384.html |
Beta Was this translation helpful? Give feedback.
-
I am a new user of Kitty. Be able to see inline images of emacs within Kitty would be just amazing! |
Beta Was this translation helpful? Give feedback.
-
Once the mimecap custom variable is added, how to open the link? Clicking a link in orgmode still opens the binary within emacs. |
Beta Was this translation helpful? Give feedback.
It looks like this requires the solution discussed in the following link.
#4021