• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 17:44
CET 23:44
KST 07:44
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
TL.net Map Contest #21: Winners2Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
Starcraft, SC2, HoTS, WC3, returning to Blizzcon!20$5,000+ WardiTV 2025 Championship5[BSL21] RO32 Group Stage3Weekly Cups (Oct 26-Nov 2): Liquid, Clem, Solar win; LAN in Philly2Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win9
StarCraft 2
General
TL.net Map Contest #21: Winners Starcraft, SC2, HoTS, WC3, returning to Blizzcon! RotterdaM "Serral is the GOAT, and it's not close" Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win 5.0.15 Patch Balance Hotfix (2025-10-8)
Tourneys
$5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest Merivale 8 Open - LAN - Stellar Fest Sea Duckling Open (Global, Bronze-Diamond) $3,500 WardiTV Korean Royale S4
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection Mutation # 495 Rest In Peace
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ SnOw's ASL S20 Finals Review [BSL21] RO32 Group Stage Practice Partners (Official) [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[Megathread] Daily Proleagues [BSL21] RO32 Group B - Sunday 21:00 CET [BSL21] RO32 Group A - Saturday 21:00 CET BSL21 Open Qualifiers Week & CONFIRM PARTICIPATION
Strategy
Current Meta How to stay on top of macro? PvZ map balance Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV Nintendo Switch Thread ZeroSpace Megathread General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine YouTube Thread Dating: How's your luck?
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Why we need SC3
Hildegard
Career Paths and Skills for …
TrAiDoS
Reality "theory" prov…
perfectspheres
Our Last Hope in th…
KrillinFromwales
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1242 users

More emacs VAssisting

Blogs > araav
Post a Reply
araav
Profile Blog Joined September 2004
Armenia1590 Posts
April 22 2009 14:47 GMT
#1
Yay, added three more Visual Assist features to my emacs. Two of them are not exactly what i wanted, but still better, much better than nothing.

This emacs thingie is really-really growing on me, its coolness and richeness are amazing!

Ok, about the added features.

Ctrl+Shift+V
This key combination pops a menu of last copied texts so you select one quickly and it's inserted. And this pasted chunk comes on top of copied things. When I started using Assist, this, along with Alt+o and Alt+m feature quickly became my top used features. I was so missing those.

After successfully implementing the Alt+o thing, I was constantly thinking about this one. I am very new in Emacs and I know those are easy things, but not for me.

Emacs has something similar to this paste menu, called "Paste from kill menu" in the "Edit" menu. But you know, when typing, it's not convenient to reach to mouse or press menu key combinations, it must be Ctrl+Shift+V, ok? How do I add new things for emacs? I do M-x ielm and the wanderful elisp interpreter appears. Her I can do whatever I want and at the end, when everything works, I just copy and paste to my .emacs.

First thing, after some trial and error, I got
(global-set-key [?\C-\S-v] 'do-paste-menu)
key combination to set up the keys to be calling the do-paste-menu function. Among some errors was that [?\C-V] was overriding the C+v too.

now my (defun do-paste-menu() ( print "hello" )) was printing my usual hello and it was already cool :-)
Next, I found from emcas include files that there was somthing called x-popup-menu. After reading its info it turned that this cool function was all I needed. Now
(defun do-paste-menu() ( let ((y (x-popup-menu t 'yank-menu))) (print y)))
was popping up the menu - my dream menu, but when I pressed it, nothing happened. Actually the content of the selected thing was prineted in the echo area. Not bad at all, but the quick replacement of 9print y) by (insert y) was inserting a lot of attributes along with the actual text. So I gave up at the moment and returned to it a couple of days later.
Long story short, my final function looks like this:
(defun do-paste-menu()
"Show and paste from menu"
(interactive)
(let* ((y (x-popup-menu t 'yank-menu)) (z (car y)))
(when (and z (> (length z) 0))
(set-text-properties 0 (length z) nil z)
(insert z))))

As it turned out, not y, but the car of y was holding the actual text and I stored it in z. And then if (when) there was anything there (the z part of and) and it it had a length of >0, then I removed its properties (set-text-properties 0 (length z) nil z) and inserted it! And voila! My ctrl+shift+v works!!!!!!!!!! Well, not exactly. In the ideal world it should also pop the pasted text and amke it my currently pasted guy and the list also contains duplicated texts, so there is still someting to work on. Will do that eventually.
The next thing, I know I did it all wrong, the menu item itself (the y guy) seems contains the actual pasting function too (emacs coolness), but I need to read up some stuff before being able to use it.

As for now, I already have the C+S+v's preliminary implementation and I am happy enough.

Alt+m
This again is one of my most favorite featrues of Visual assist. You press alt+m, the list of functions appears of an editable combo box, you then type in some letters and it selects the function from that combo box. It's so quick and easy, after some time you do not even remember the sequence of the functions. Not only you forget it, you don't even think about it, it becomes abstracted. Now one needs to be careful with this though. Indeed if you just type in functions regardless of their places, that would fuck up the structure of the object file and in some cases even the program's performance (this is quiet an advanced topic, so will not touch for now, go read some Drepper papers for that).
Back to the emacs. Apparently emacs' speedbar is a nice feature and it parses and dynamically updates the list of functions. But again... it's interface for this particular use case is too complcated. You need to
- switch to it (alt+zero for me)
- press +
- find your function
- press enter

As a result the list remains opened and a valuable vertical space is wasted. Though speedbar's added green overlay on top of the just visited function is sweet.

It turned out emacs already has a nice way of doing this and it's called imenu. Speedbar internally uses imenu's features to construct its items. Imenu has a feature of adding a menu item "Index" to the main menu, the contents of which is what I want. Imenu also offers a way of showing a menu for the M-x imenu command. It can have three values - Mouse event, Always, Never.
If it's bound to a mouse event, a menu is indeed appears. I want keyboard, so I selected "Always". It didn't work... what a pity. Again, I ended up with the following code -
;; go-to-definition-menu
(defun my-imenu-helper()
(let (index-alist
(result t)
alist)
;; Create a list for this buffer only when needed.
(while (eq result t)
(setq index-alist (imenu--make-index-alist))
(setq result (imenu--mouse-menu index-alist t))
(and (equal result imenu--rescan-item)
(imenu--cleanup)
(setq result t imenu--index-alist nil)))
result))

(defun my-imenu() (interactive) (imenu (my-imenu-helper)))
(global-set-key [?\M-\m] 'my-imenu)

The function my-imenu-handler was taken from imenu's codes and modified to meet my needs. The original function was bound to use mouse event which made it unusable as it was. So its modified coppy appears in my .emacs. The (imenu ....) call does the goto part to the place which the handler returns.

This works, I press Alt+M and the menu appears. This is good again, but it's again not what I really wanted. I want to have the filtering method - I want a combo box solution!

Alt+g
Or open the include file!
If you do Alt+g on line
#include "myfile.h"
and your cursor is somewhere between the "", visual assist opens the myfile.h. This again is a nice feature, which cuts a lot of speedbar usage.

After some ielming, I got the following code working for me:
(defun hoper-src(env) (let ((p (getenv env))) (if p (concat (file-name-as-directory p) "hoper/src") nil)))
(defun src-path () (list "." (hoper-src "LOCAL_BUILD") (hoper-src "GLOBAL_BUILD")))
(defun line-incl-fln(str) (when (string-match "^[[:space]*#[[:space]*include[[:space]+[\"\<]\\(.*\\)[\"\>][[:space]*$" str)
(match-string-no-properties 1 str)))
(defun incl-fln() (line-incl-fln (thing-at-point 'line)))
(defun open-incl-fln(str) (let ((fln (locate-file str (src-path)))) (find-file fln)))
(defun open-include-file()
"Open the C/C++ include file under cursor"
(interactive)
(let ((fln (incl-fln))) (when fln (open-incl-fln fln))))
(global-set-key [M-\kp-multiply] 'open-include-file)
(global-set-key [M-\kp-decimal] 'open-include-file)

Some things to mention.
(src-path) returns the list of directories to search for a file. It always includes the current directory and also I've added the directories for my company's project, which I mention as "hoper" (intentional change).
The funtion line-incl-fln parses the argument of form #include "file" or and returns the FILE part (well, it also accepts "file> and &lt file", but it's a feature, not a bug [while blogger.com's complaining about my &ltfile incomplete key and eating it through the end of line is indeed a bug - wtf]).
The rest is just taking the current line (thing-at-point 'line), and searching it through find-file.
I could not bind it to Alt+g, so I went with both Alt+Keypad * and Alt+"Keypad .". The . one is similar to the default Alt+. aka goto definition and the * one is similar to goto current line of the visual studio debugger. Although totally different, but somehow it looked at least familiar for me.

Off now, will continue later...

The flower that blooms in adversity is the most rare and beautiful of all.
Please log in or register to reply.
Live Events Refresh
OSC
22:00
Masters Cup 150 Open Qual
davetesta29
Liquipedia
LAN Event
18:00
Day 3: Ursa 2v2, FFA
SteadfastSC445
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SteadfastSC 456
White-Ra 296
ProTech115
JuggernautJason30
StarCraft: Brood War
Shuttle 454
Bonyth 130
UpATreeSC 112
NaDa 12
Counter-Strike
Foxcn101
Super Smash Bros
AZ_Axe73
Liquid`Ken27
Heroes of the Storm
Liquid`Hasu518
Other Games
tarik_tv13122
fl0m794
shahzam422
FrodaN294
ToD219
Pyrionflax206
C9.Mang0135
ArmadaUGS83
Mew2King80
PPMD21
Organizations
Counter-Strike
PGL166
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• Hupsaiya 51
• musti20045 30
• Dystopia_ 4
• Migwel
• sooper7s
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• mYiSmile18
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• Ler77
League of Legends
• TFBlade1056
Other Games
• imaqtpie1516
• Scarra520
• Shiphtur182
Upcoming Events
Replay Cast
16m
OSC
13h 16m
LAN Event
16h 16m
Korean StarCraft League
1d 4h
CranKy Ducklings
1d 11h
LAN Event
1d 16h
IPSL
1d 19h
dxtr13 vs OldBoy
Napoleon vs Doodle
BSL 21
1d 21h
Gosudark vs Kyrie
Gypsy vs Sterling
UltrA vs Radley
Dandy vs Ptak
Replay Cast
2 days
Sparkling Tuna Cup
2 days
[ Show More ]
WardiTV Korean Royale
2 days
LAN Event
2 days
IPSL
2 days
JDConan vs WIZARD
WolFix vs Cross
BSL 21
2 days
spx vs rasowy
HBO vs KameZerg
Cross vs Razz
dxtr13 vs ZZZero
Replay Cast
3 days
Wardi Open
3 days
WardiTV Korean Royale
4 days
Replay Cast
5 days
Kung Fu Cup
5 days
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
Tenacious Turtle Tussle
6 days
The PondCast
6 days
RSL Revival
6 days
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
6 days
WardiTV Korean Royale
6 days
Liquipedia Results

Completed

BSL 21 Points
SC4ALL: StarCraft II
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025

Upcoming

BSL Season 21
SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
Stellar Fest: Constellation Cup
META Madness #9
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.