• emacs从缓冲中获取信息,并执行shell 命令


    /* author: hjjdebug
    *  date : 2023年 09月 20日 星期三 11:39:11 CST
    *  description: emacs从缓冲中获取信息,并执行shell 命令
    */
    我有一个udp频道的列表,如下:
    239.3.1.105:8092     |  IP 61.135.101.121.8046 >
    239.3.1.124:8128     |  IP 61.135.101.118.8050 >
    239.3.1.129:8008     |  IP 61.135.101.121.8054 >
    239.3.1.132:8012    |  IP 61.135.101.121.8058 >
    其中 | 以前部分是udp 地址, 后面 IP 部分信息不重要,是说该udp是哪个机器发出的.
    我现在想把光标放到某一行,然后敲一个按键就能播出该udp码流,如何实现?

    当然,这需要两步走,
    第一步: 获取所在行的url信息
    第二步: 调用ffplay 命令,例如
    当放在第一行时,它应该调用 ffplay udp://239.3.1.105:8092

    第一步: 千回百转,我找到了 buffer-substring-no-properties函数
    并书写了line_info 从光标所在行获取感兴趣的东西, 从此elisp 再进一步
    (defun line_info()
      "get some useful info from line."
      (interactive)
      (move-beginning-of-line nil)
      (setq start (point))
      (search-forward "|")
      (backward-char)
      (setq end (point))
    ;;  (message (buffer-substring-no-properties start end))
      (buffer-substring-no-properties start end)
      )

    第二步: 我调用了shell-command() 函数
    并书写了emacs 中ffplay 函数, 来调用外部ffplay 函数,并传递给它参数
    (defun ffplay()
      "use ffplay in emacs."
      (interactive)
      (shell-command (concat "ffplay " "udp://" (line_info))
      ))

    第三步: 把命令定义到一个快捷键上,例如定义到C-c r按键上,这个简单
    (global-set-key (kbd "C-c r") `ffplay)

  • 相关阅读:
    [Linux Review-2] Linux OS fundamental #102
    对C语言函数的再认识
    PDF24 Creator PDF工具箱 v11.17.0
    git常用命令
    k8s配置集ConfigMap详解
    实时监控网页变化,并增加多种提示信息
    Spring Authorization Server OAuth 2.0获取授权码流程
    SPSS多元方差分析
    Android学习笔记 41. Gson
    SaaSBase:艺赛旗iS-RPA是什么?
  • 原文地址:https://blog.csdn.net/hejinjing_tom_com/article/details/133073186