Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
09-24-2013, 09:53 AM
|
#1
|
Member
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609
|
[Request] Slackpkg custom merge tool.
Hi,
I checked slackpkg sources, and found that it was using sdiff to merge configurations files.
I'd like to use another merge tool (emacs to be precise  ).
Would it be possible to make the merge tool customizable ?
It would be great to be able to change the sdiff default using an environment variable.
If any help needed, I'd be glad to participate (at least for testing  ).
Thanks !
Bests,
Garry.
Edit: It could be in slackpkg.conf too, but an external environment variable could make this more "versatile".
Last edited by NoStressHQ; 09-24-2013 at 09:58 AM.
|
|
|
09-24-2013, 10:15 AM
|
#2
|
Senior Member
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,849
|
so that means all users wanting to use slackpkg should install emacs?
i don't think most users will agree on this one
i personally don't install emacs and i think sdiff works for me
|
|
1 members found this post helpful.
|
09-24-2013, 10:18 AM
|
#3
|
Member
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609
Original Poster
|
Quote:
Originally Posted by willysr
so that means all users wanting to use slackpkg should install emacs?
i don't think most users will agree on this one
i personally don't install emacs and i think sdiff works for me
|
That's not at all what I wrote...
I asked to be able to choose which merge tool you want to use. With an environment variable. I mentioned emacs just because it's the one I want to use in my particular situation...
|
|
|
09-24-2013, 10:22 AM
|
#4
|
Senior Member
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,849
|
i guess the main important is what's the advantage of using emacs compared to sdiff?
|
|
|
09-24-2013, 10:27 AM
|
#5
|
Member
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609
Original Poster
|
Quote:
Originally Posted by willysr
i guess the main important is what's the advantage of using emacs compared to sdiff?
|
... Is it a joke ? Do I tell you how you need to work ?
|
|
|
09-24-2013, 10:32 AM
|
#6
|
Moderator
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
|
Quote:
Originally Posted by NoStressHQ
... Is it a joke ? Do I tell you how you need to work ?
|
willysr indeed has a point there. Having multiple options for that means that someone has to implement and test that every time changes are made to slackpkg, with all possible options. If there isn't an obvious advantage of using Emacs or anything else to do the job I don't see why the developer should add this.
But I am really curious about that, what exactly do you want to achieve with the switch to Emacs?
|
|
|
09-24-2013, 10:36 AM
|
#7
|
Senior Member
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,849
|
no, it's not a joke
i know emacs is a great application and some might like it and prefer it compared to vi or nano, but i don't see anything different with the results of diff by changing to emacs (please, CMIIW)
|
|
|
09-24-2013, 10:41 AM
|
#8
|
Member
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609
Original Poster
|
Quote:
Originally Posted by TobiSGD
willysr indeed has a point there. Having multiple options for that means that someone has to implement and test that every time changes are made to slackpkg, with all possible options. If there isn't an obvious advantage of using Emacs or anything else to do the job I don't see why the developer should add this.
But I am really curious about that, what exactly do you want to achieve with the switch to Emacs?
|
Alright, that's a better approach to the question. At least I cant understand your point about maintainability.
It's before all a matter of being more productive to be able to use the tool you're used to use in your daily tasks. That's seems obvious to me.
Beside I don't ask for emacs (I thought my OP was clear about that)...
I ask to be able to have an environment variable to be able to customize.
Default would be ie:
Code:
SLACKPKG_MERGE_TOOL=sdiff -s -o
And people would be able to do something else
Code:
SLACKPKG_MERGE_TOOL=mymergetool-of-my-choice --with --my --args
That's it. I might be wrong but those modifying (customizing) this variable should be aware enough to understand how it works and being responsible to maintain their own customization.
I use emacs, but many others use vim so I'm not doing some "emacs evangelization" and don't want to enter in this mode...
I was just talking about giving slackpkg some more flexibility.
And I'm open to any point which could be about "not in the plan" or "difficult to maintain" although I really don't see (I might be wrong) any difficult problem here.
In practice it could even be a wrapper script that shuffle arguments if the wanted merge tool is too exotic.
Thanks
Garry.
Last edited by NoStressHQ; 09-24-2013 at 10:52 AM.
Reason: fixed typos
|
|
|
09-24-2013, 10:45 AM
|
#9
|
Member
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609
Original Poster
|
Quote:
Originally Posted by willysr
no, it's not a joke
i know emacs is a great application and some might like it and prefer it compared to vi or nano, but i don't see anything different with the results of diff by changing to emacs (please, CMIIW)
|
Ok sorry I took it badly, it's just it was not at all the point of my post.
And I don't see the need to argue "which one is better" because ultimately, it's a matter of choice, is it personal or professional/corporate... Anyway.
I'm not saying sdiff is rubbish, sdiff is good when you don't have anything else accessible.
I'd just rather use emacs for that, it's a choice as any choice.
Edit: obviously, I hope there's no difference in the 'result of diff' haha... It's on the way you do the merge, which color you want etc. Usability in short, productivity for a longer word.
Edit2: also it's less error prone to use something you're used to use... And config files merges can sometimes be "sensible".
Edit3: sorry, I can understand the problem now, I'm talking about having 'interactive merge tool'. And now I see that it might introduce more changes in slackpkg behavior. But I guess it's not something impossible. So that was maybe the source of misunderstanding. But sdiff is interactive too so at the end, it seems to me that the point is the same.
Last edited by NoStressHQ; 09-24-2013 at 11:28 AM.
|
|
|
09-24-2013, 05:34 PM
|
#10
|
LQ 5k Club
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,551
|
Slackpkg is designed to be easy to customise. I actually implement a custom merge using vimdiff. I find it useful for updating large config files with custom entries e.g. for cups and ssh. Adapting this for emacs should not be difficult.
I edit /usr/libexec/slackpkg/functions.d/postfunctions.sh
Code:
--- post-functions.sh.orig 2013-02-21 21:07:05.408637573 +1100
+++ post-functions.sh 2013-02-21 22:08:22.885260049 +1100
@@ -10,6 +10,18 @@
fi
}
+runvimdiff() {
+ BASENAME=$(basename $i .new)
+ FILEPATH=$(dirname $i)
+ FULLNAME="${FILEPATH}/${BASENAME}"
+
+ if [ -e ${FULLNAME} ]; then
+ vimdiff ${FULLNAME} ${FULLNAME}.new
+ else
+ echo "file $FULLNAME doesn't exist"
+ fi
+}
+
showmenu() {
echo -e "$1 - \c"
tput sc
@@ -166,7 +178,7 @@
GOEX=0
while [ $GOEX -eq 0 ]; do
echo
- showmenu $i "(K)eep" "(O)verwrite" "(R)emove" "(D)iff" "(M)erge"
+ showmenu $i "(K)eep" "(O)verwrite" "(R)emove" "(D)iff" "(M)erge" "(V)imdiff [dp put, do obtain, ^W^W switch]"
read ANSWER
case $ANSWER in
O|o)
@@ -183,6 +195,9 @@
M|m)
mergenew $1
;;
+ V|v)
+ runvimdiff $1
+ ;;
K|k|*)
GOEX=1
;;
|
|
1 members found this post helpful.
|
09-24-2013, 06:02 PM
|
#11
|
Member
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609
Original Poster
|
Quote:
Originally Posted by allend
Slackpkg is designed to be easy to customise. I actually implement a custom merge using vimdiff. I find it useful for updating large config files with custom entries e.g. for cups and ssh. Adapting this for emacs should not be difficult.
I edit /usr/libexec/slackpkg/functions.d/postfunctions.sh
|
Yes, that's what I meant !
I know this file, it's just I'd rather not modify/patch it, and I myself don't want to use emacs all the time. That's why I was talking about an environment variable... In the function mergenew(),
instead of:
Code:
sdiff -s -o "${FULLNAME}.smerge" "${FULLNAME}" "${FULLNAME}.new"
it could be:
Code:
$SLACKPKG_MERGE_TOOL "${FULLNAME}.smerge" "${FULLNAME}" "${FULLNAME}.new"
While in slackpkg.conf we could have (bash syntax, dunno for "pure" /bin/sh):
Code:
SLACKPKG_MERGE_TOOL=${SLACKPKG_MERGE_TOOL:-sdiff -s -o}
Then slackpkg should work as usual, but if we want a another merge tool we could just set the SLACKPKG_MERGE_TOOL variable to the right command...
As simple as this. No one lose anything, does it ?
Cheers
Garry.
Last edited by NoStressHQ; 09-24-2013 at 09:34 PM.
Reason: Added the forgotten '$' on variable reference :).
|
|
|
09-24-2013, 07:52 PM
|
#12
|
LQ 5k Club
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,551
|
I find that having another menu entry is more convenient than setting an environment variable.
Editing postfunctions.sh is only a problem when it gets overwritten by a package update.
|
|
|
09-24-2013, 08:04 PM
|
#13
|
Member
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609
Original Poster
|
Quote:
Originally Posted by allend
I find that having another menu entry is more convenient than setting an environment variable.
Editing postfunctions.sh is only a problem when it gets overwritten by a package update.
|
Well here are my points:
- consistency: it's like the common $EDITOR env var used in many places.
- complexity: a menu requires more modification and imply to know which options you want to provide, and each must be tested upstream (this might become a PITA for developers)
- flexibility: a variable can be set to anything the user want, even a yet unknown tool or a wrapper script that provide an "unified" interface.
Plus you can set the variable in a script (or the .bashrc file) and it's not difficult.
On my point of view the variable is more "UNIX" in style and flavor, it's a very tiny modification and open to more choice.
BTW, it's my developer reflex and my preference, I don't know what slackpkg developers prefer, it's up to them.
|
|
|
09-24-2013, 08:09 PM
|
#14
|
LQ 5k Club
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,551
|
One argument for avoiding using emacs is that it requires X to be running. I prefer to do my upgrades from run level 3, so vimdiff is a viable choice for that.
|
|
|
09-24-2013, 08:12 PM
|
#15
|
Member
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609
Original Poster
|
Quote:
Originally Posted by allend
One argument for avoiding using emacs is that it requires X to be running. I prefer to do my upgrades from run level 3, so vimdiff is a viable choice for that.
|
Have you noticed "emacs-24.2-no-x11" ? As a matter of fact I got an alias as "emacs-console" for my headless server...
(Edit: And even in graphical environment I tend to use the console version of emacs...)
|
|
|
All times are GMT -5. The time now is 07:19 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|