เปิดบัฟเฟอร์ "display-buffer" ในแท็บใหม่
display-bufferฟังก์ชั่นที่ดูเหมือนว่าจะใช้ค่อนข้างหนักภายใน Emacs มีตัวเลือกมากมายในการกำหนดตำแหน่งที่จะเปิดบัฟเฟอร์ใหม่ (หน้าต่างใหม่เฟรมใหม่หน้าต่างที่มีอยู่ ฯลฯ )
Emacs นำเสนอแนวคิดของแท็บใน 27.1 อย่างไรก็ตามดูเหมือนจะไม่มีวิธีง่ายๆในการบอกdisplay-bufferว่าคุณต้องการให้เปิดบัฟเฟอร์ใหม่ในแท็บแทนที่จะเป็นเพียงหน้าต่างใหม่
มีวิธีกำหนดค่าdisplay-bufferเพื่อเปิดบัฟเฟอร์ทั้งหมดในแท็บใหม่ (หรือที่มีอยู่?) หรือไม่?
วิธีแก้ปัญหาจากNickDแนะนำให้ใช้ฟังก์ชันเช่นdisplay-buffer-in-tab.
ฉันสามารถทำงานนี้ได้โดยการตั้งค่าdisplay-buffer-base-actionดังต่อไปนี้:
(setq display-buffer-base-action '(display-buffer-in-tab))
แต่นี้ไม่ได้ดูเหมือนจะเล่นอย่างกับการทำงานเช่นการและhelp magit-statusพวกเขามักจะเปิดแท็บมากเกินไปทุกครั้งที่เรียกใช้
การตั้งค่าที่เฉพาะเจาะจงมากขึ้นอาจจำเป็นต่อคำสั่งหรือต่อบัฟเฟอร์ใหม่
คำตอบ
มีdisplay-buffer-in-new-tab. สตริงเอกสารระบุว่า:
display-buffer-in-new-tab is a compiled Lisp function in ‘tab-bar.el’.
(display-buffer-in-new-tab BUFFER ALIST)
Display BUFFER in a new tab.
ALIST is an association list of action symbols and values. See
Info node ‘(elisp) Buffer Display Action Alists’ for details of
such alists.
Like ‘display-buffer-in-tab’, but always creates a new tab unconditionally,
without checking if a suitable tab already exists.
If ALIST contains a ‘tab-name’ entry, it creates a new tab with that name
and displays BUFFER in a new tab. The ‘tab-name’ entry can be a function,
then it is called with two arguments: BUFFER and ALIST, and should return
the tab name. When a ‘tab-name’ entry is omitted, create a new tab without
an explicit name.
This is an action function for buffer display, see Info
node ‘(elisp) Buffer Display Action Functions’. It should be
called only by ‘display-buffer’ or a function directly or
indirectly called by the latter.
ยังไม่ทดสอบ
แก้ไข: ฉันพบสิ่งนี้โดยใช้ระบบช่วยเหลือ Emacs ฉันไม่ได้ใช้tab-bar-modeและฉันไม่รู้เกี่ยวกับเรื่องนี้มาก่อน แต่การทำC-h f display-buffer-TABแสดงให้ฉันเห็นบัฟเฟอร์ที่สมบูรณ์ ฉันพบสิ่งนั้นอย่างรวดเร็วdisplay-buffer-in-tabและ display-buffer-in-new-tabฉันเลือกอย่างหลังและได้รับสตริง doc ที่ฉันวางไว้ด้านบน
หากเสร็จสิ้นบัฟเฟอร์ยาวเกินไปที่จะสแกนได้อย่างง่ายดายด้วยตาคุณสามารถสลับไปยังบัฟเฟอร์ที่มีC-x oแล้วก็ค้นหาเช่นสำหรับในบัฟเฟอร์ใช้tabC-s
การเรียนรู้การใช้งานHelpและการเรียนรู้ที่จะค้นหาผ่านคู่มือด้วยInfoเป็นการลงทุนที่ดีเยี่ยมสำหรับเวลาของคุณ