Removing items while they're displayed in a DF viewscreen probably isn't safe. If you're making a UI to stack items, you could probably implement a simplified list in lua, but it would have the disadvantage of not having the options of the native viewscreen (I'm not sure how necessary you consider that).
Anyway, you ought to be able to remove an item from a viewscreen listing multiple items from lua, as well as the corresponding refs, but I'm not sure how safe that is.
Yeah, it's possible, and I wrote a script that does it. It didn't crash immediately, or after running the game for half a minute, and the item does disappear from df.item.find(), so it's probably safe. It depends on how DF does its memory management internally. If, internally, it uses reference-counted smart pointers, then as long as it doesn't do anything obscene with them it should be fine.
It doesn't update the inventory screen to show removals in real time, though, which makes it less useful as something to release to the public. I'll probably just write something ugly that solves the minor inconvenience I had and keep it to myself. (You know, two scripts, one to mark items for merging while you're in the inventory screen, storing their IDs in a persist table, the second to actually carry out the merges after exiting the inventory screen.)
I suppose I could still write a plugin that automatically merges stacks as items are added to containers (and containers to stockpiles), but I don't know how many people would care to have a utility like that. Personally, I really think it should just be something DF does automatically. It's kind of absurd the way the game handles stacks of items, really. A cook grabs a stack of 30 eggs and a stack of one quarry bush leaf and figures that's a reasonable pairing? And that takes the same amount of time to cook as four stacks of 30 eggs, or two stacks of one strawberry? Instead of picking up stacks from containers, dwarves should make stacks in their hands by taking items, and try to hit a target stack size. So, when a cook decides to add eggs as the next ingredient to a meal, they should try to collect (say) six eggs from the available stocks, even if that requires splitting and merging available item stacks. Same deal with crossbow bolts. Dwarves should just fill their quiver from the available stocks.
It's a minor gripe, I know, like the fact that you can't select material types for most jobs (though there is a script for that), but it's one of those little things that just sticks in my craw for some reason.